Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variation without the shims? #145

Closed
srinivas-os opened this issue Apr 1, 2016 · 4 comments
Closed

Variation without the shims? #145

srinivas-os opened this issue Apr 1, 2016 · 4 comments
Assignees
Milestone

Comments

@srinivas-os
Copy link

Firstly, apologies in advance for my tone and naivete if any. English is not my first language, nor is Javascript :-).

I use this excellent library in conjunction with LoopbackJS. When I do JSON.stringify of a loopback model object, the array attributes are output in object form instead of array form (i.e. flower brackets {} in the JSON as opposed to square brackets []).

On deeper inspection, I found that Loopback is calling toObject method on all model attributes (including array attributes), when JSON.stringify is done. Since normally Array type in JS does not have toObject implemented, it gets ignored silently, and array's default JSON representation ([]) is used. But since the collectionsJS library shims Array with a bunch of methods including toObject, call goes there instead and the array is converted to an object.

I could instead file a request with LoopbackJS team to not call toObject for arrays. But I am not sure if this shimming affects other modules as well in other unknown ways.

Would it be possible to release a version of your wonderful CollectionsJS library without the shims? Or is there already such a fork? I would really hate to look for other libraries or cook up my own implementation of the various data structures just because I want to avoid the shims.

@srinivas-os
Copy link
Author

OK, I just saw #95. Can I use 2.0.2 version of this library to resolve my issue? Would I be missing out on major bug fixes and such? The collection I am most interested in is sorted set.

@kriskowal
Copy link
Member

@srinivas-os Yes, version 2 should suffice for SortedSet sans shims.

@hthetiot
Copy link
Contributor

hthetiot commented Dec 7, 2017

Duplicate #185

@codebling
Copy link

See also issues #36 #70 #94 #95 #116 #139 #145 #162 #165 #169 #178 #182 #185 #197 #215 #220 and PRs #94 #95 #116 #173 #189 #212. Branch v2 fixes these issues by avoiding global object modification.

This was referenced Apr 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants