You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Underscore returns incorrect results for Set objects. E.g. believes they are empty when they are not. I assume other Underscore functions for iteration, inclusion testing, and so on will similarly fail.
~$ node
> u = require('underscore')
...
> s = new Set()
Set {}
> u.isEmpty(s)
true
> s.add(44)
Set { 44 }
> u.isEmpty(s)
true
> u.size(s)
0
> u.VERSION
'1.8.3'
Several open issues mention ES2015 Set and Map (e.g. this one); none seem the same as this bug. Reading source for v1.9.0, it seems to rely on defaultKeys (alias for Object.keys). Object.keys does not produce keys for Set objects, so this is likely to fail in the same ways it does now. Similarly _.size seems to rely on the the .length property, which Set does not have; it has an idiosyncratic .size property instead, which the source does not seem to query.
Set objects are new, and seem very immature. Still, when JS fails to do the right thing, I look to Underscore to make things right, or at least a little more logical. Hoping that a near release can help wrangle the new structures.
The text was updated successfully, but these errors were encountered:
Considering taking a crack at it. Slightly daunted by the need to redefine core functions (e.g. getLength, nativeKeys) to incorporate Set and Map, or to add alternative logic paths ("are we dealing with these newfangled types? Okay, well then...") to a wide variety of Underscore functions. It's a considerable surgery for a first-time contributor. Any guidance?
Trust the tests. We have very good test coverage. As long as all existing tests continue to pass, you can assume you haven't broken anything too meaningful.
Feel free to open incomplete pull requests for early feedback. If you are unsure if you are on the right track, we can point you in the right direction.
Underscore returns incorrect results for
Set
objects. E.g. believes they are empty when they are not. I assume other Underscore functions for iteration, inclusion testing, and so on will similarly fail.Several open issues mention ES2015
Set
andMap
(e.g. this one); none seem the same as this bug. Reading source for v1.9.0, it seems to rely ondefaultKeys
(alias forObject.keys
).Object.keys
does not produce keys forSet
objects, so this is likely to fail in the same ways it does now. Similarly_.size
seems to rely on the the.length
property, whichSet
does not have; it has an idiosyncratic.size
property instead, which the source does not seem to query.Set
objects are new, and seem very immature. Still, when JS fails to do the right thing, I look to Underscore to make things right, or at least a little more logical. Hoping that a near release can help wrangle the new structures.The text was updated successfully, but these errors were encountered: