1.0.1 • Published 6 months ago
safeset v1.0.1
safeset 
Set, but safe from prototype modifications.
Getting started
npm install --save safeset
Usage/Examples
const assert = require('assert');
const SafeSet = require('safeset');
delete Set.prototype.has;
delete Set.prototype.size;
delete Set.prototype[Symbol.iterator];
const set = new Set([1, 2]);
assert.equal('has' in set, false, 'set has no `has`!');
assert.equal(set.size, undefined, 'set size is not 2!');
assert.deepEqual(Array.from(set), [], 'set is missing expected values!');
const ss = new SafeSet([1, 2]);
assert.equal(ss.has(1), true, 'safe set has 1');
assert.equal(ss.size, 2, 'safe set size is 2');
assert.deepEqual(Array.from(ss), [1, 2], 'safe set has expected values');
Tests
Clone the repo, npm install
, and run npm test