rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.37k stars 195 forks source link

flatMap (and possibly others) sends strings for index #36

Closed rtfeldman closed 9 years ago

rtfeldman commented 9 years ago
Immutable(["foo", "bar"]).flatMap(function(val, index) {
  return "index is " + index + " aaaand its type is " + (typeof index);
});

// [ 'index is 0 aaaand its type is string', 'index is 1 aaaand its type is string' ]

The offending line of code: https://github.com/rtfeldman/seamless-immutable/blob/master/src/seamless-immutable.js#L124

Evidence suggests that second argument needs to be parseInt(key) which is absolutely gobsmacking.

rtfeldman commented 9 years ago

This is now fixed more efficiently by https://github.com/rtfeldman/seamless-immutable/commit/af6a8dfd7e2f1939e5108aae118b9270cb9bff3a