Skip to content

Collections.js is not loading correctly #158

@bugs181

Description

@bugs181

This was a tricky bug to track down.

Taking the code directly from the examples gives me some very weird results. The issue (in this case) is because the library isn't overriding built-ins.

Let me elaborate.

var Set = require("collections/set")

var object = { x: "hello" }
var set = new Set(["a", object])

console.log( set.add("b") )
// Expected: true
// Result: Set { 'a', { x: 'hello' }, 'b' }

console.log( set.toArray() )
// Expected: ["a",{"x":"hello"},"b"]
// Result: [ 'a', { x: 'hello' }, 'b' ]

console.log( set.add(object) )
// Expected: false
// Result: Set { 'a', { x: 'hello' }, 'b' }

console.log( set.toArray() )
// Expected: ["a",{"x":"hello"},"b"]
// Result: [ 'a', { x: 'hello' }, 'b' ]

In fact, removing the first line gives the exact same output. This leads me to believe that Set is using the built-in operator.

My setup is as follows:

OS:
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.10.1
BuildVersion: 14B25

Install:
$ npm install --save collections

Node version:
$ node -v
v5.10.0

npm version:
$ npm -v
3.8.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions