Skip to content

collections breaks Array.from with Iterables #169

@akloeber

Description

@akloeber

collections breaks Array.from with Iterables. This can be reproduced with the following code:

var obj = {};
obj[Symbol.iterator] = function() {
  var values = ['foo', 'bar'];

  return {
    next: function() {
      var done = values.length === 0;
      var value = done ? undefined : values.shift();

      return {
        value: value,
        done: done
      };
    }
  };
};

console.log('before collections load:', Array.from(obj));
require('collections/sorted-map');
console.log('after collections load:', Array.from(obj));

Output:

$ node test.js
before collections load: [ 'foo', 'bar' ]
after collections load: []

Environment:
collections v5.0.6
node v4.4.7
Mac OS X 10.12.2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions