1.1.0 • Published 6 years ago
spicy-set v1.1.0
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 = SpicySet();
vanillaSet.add({ hello: 'world' });
spicySet.add({ hello: 'world' });
vanillaSet.has({ hello: 'world' }); // output: false
spicySet.hasObject({ hello: 'world' }); // output: true
vanillaSet.add({ hello: 'world' }); // Adds object, Set is { {hello: 'world'}, {hello: 'world'} }
spicySet.addObject({ hello: 'world' }); // Doesn't add object, Set is { {hello: 'world'} }
Scripts
- unit tests:
npm test
- html test coverage:
npm run html
- build and view docs:
npm run docs
Help
Why? JavaScript evaluates objects by reference and not value.