-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Inclusion of "collections" package breaks my project unit tests #1392
Comments
#1386 updates collections.js It might help to solve your problem. See
montagejs/collections#241 (comment) As I commented, updating the intrinsic container (Array) is not good. But collections.js mentioned
I think that it is very limited extention. However, if we get the same functionality without intrinsic library updates such as Array, it is better.
Thank you. collections is used for two purposes. One is LRU map, the other is SortedSet. LRU map https://www.collectionsjs.com/lru-mapSee https://github.com/mqttjs/MQTT.js/blob/f04c24bd082aa9f6db2da6da65e40b2e0b692bcc/lib/topic-alias-send.js getMQTT.js/lib/topic-alias-send.js Line 38 in f04c24b
Get value from key with touch (Use updating) setMQTT.js/lib/topic-alias-send.js Line 38 in f04c24b
lengthMQTT.js/lib/topic-alias-send.js Line 45 in f04c24b
clearMQTT.js/lib/topic-alias-send.js Line 77 in f04c24b
Overwriting by new object is acceptable solution. get least used elementMQTT.js/lib/topic-alias-send.js Line 90 in f04c24b
It is not commonly supported. But it is very important feature to implement Topic Alias. One candidate I found is https://www.npmjs.com/package/quick-lru. I think that it is covered full required functionality. Sorted Set https://www.collectionsjs.com/sorted-setIt is used for unique (unconflict) messageId (Packet Identifier) allocation. length if (this.ss.length === 0) return null get minimum element const it = this.ss.min() delete minimum element this.ss.shift() Erase specific element by iterator (cursor) or key can be used. get matched element otherwise the next element const it = this.ss.findLeastGreaterThanOrEqual(key) Let's say collection has delete element by iterator (cursor) or key this.ss.delete(it.value) insert element this.ss.push(new Interval(low, num - 1)) get matched element otherwise the previous element const it = this.ss.findLeastGreaterThanOrEqual(key) Let's say collection has It can be achieved clear this.ss.clear() Overwriting by new object is acceptable solution. I found https://www.npmjs.com/package/js-sdsl . It asmost cover all functionalities. But it doesn't support So I started migrating SortedSet from collections.js to Set from js-sdsl. The current status
|
Since number-allocator https://www.npmjs.com/package/number-allocator 1.0.9, js-sdsl https://www.npmjs.com/package/js-sdsl is used insteaad of collections https://www.npmjs.com/package/collections. collections modify intrinsic type such as Array, it has unexpected side effect for users. So I removed the dependency of collections. It is a partial fix for mqttjs#1392. Replacement for LRU map is still needed to remove collections dependency.
#1394 replaced SortedSet from collections to js-sdsl. So one of collections dependency is removed. |
This issue causes troubles when using MikroORM and |
Since number-allocator https://www.npmjs.com/package/number-allocator 1.0.9, js-sdsl https://www.npmjs.com/package/js-sdsl is used insteaad of collections https://www.npmjs.com/package/collections. collections modify intrinsic type such as Array, it has unexpected side effect for users. So I removed the dependency of collections. It is a partial fix for #1392. Replacement for LRU map is still needed to remove collections dependency.
release 4.3.3 should resolve this issue. please let me know. |
I'll look into it tomorrow in the morning and let you know if 4.3.3 solves
it.
Thanks
…On Wed, 5 Jan 2022, 18:38 Yoseph Maguire, ***@***.***> wrote:
release 4.3.3 should resolve this issue. please let me know.
—
Reply to this email directly, view it on GitHub
<#1392 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHWFMCLXIRXIX6LD2ZVVALUUR6XPANCNFSM5LGY75FA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
It does not solve the issue describe in this comment above. The issue is that Once again: this issue is better described by @B4nan in this comment and following ones. Update Last version without I love |
I found good candidate of LRU map container. |
It seems that I found better one. I just started replacing. |
@tukusejssirs yeah we're doing a full rewrite so we can make sure the testing infra protects changes in the future from breaking things like this. rn testing is sh*t unfortunately... that is why problems like this keep occuring. |
let me know if 4.3.4 fixes this issue now... |
It works as expected! Thanks, @YoDaMa! 💯 🙏 |
closing issue as resolved. |
Starting with 4.3.0 the library takes a dependency on the collections package.
I can't find any references to such package, but I suspect that is because it "patches" (modifies the prototype) of several objects, so I cannot suggest a different way to do things without taking that dependency.
The errors I am getting are the same as the ones described in: sinonjs/commons#18, however I cannot workaround them as suggested.
I would really like to upgrade to the latest version, but as of now, I have to stay in 4.2.8 as it does not take dependency on the collections library).
I'd really like to suggest eliminating the dependency on a library that is prone to break other people's code due to their modification of prototypes (https://github.com/montagejs/collections/issues?q=is%3Aissue+is%3Aopen+break).
Maybe I could give a hand if I knew what the package is used for.
Thanks in advance
The text was updated successfully, but these errors were encountered: