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.
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.