spicy-set
v2.0.0
Published
Creates Set methods for interacting with objects based on content instead of reference
Downloads
7
Readme
Spicy Set 🔥
Creates Set
methods for interacting with objects based on content instead of reference.
Usage
const SpicySet = require('spicy-set');
const vanillaSet = new Set();
const spicySet = new SpicySet();
vanillaSet.add({ hello: 'world' });
spicySet.add({ hello: 'world' });
vanillaSet.has({ hello: 'world' }); // output: false
spicySet.has({ hello: 'world' }); // output: true
vanillaSet.add({ hello: 'world' }); // Adds object, Set is { {hello: 'world'}, {hello: 'world'} }
spicySet.add({ hello: 'world' }); // Doesn't add object, Set is { {hello: 'world'} }
Scripts
- unit tests:
npm test
Help
Why? JavaScript evaluates objects by reference and not value.