Skip to content

Repository files navigation

safeset Version Badge

github actions coverage License Downloads

npm badge

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

About

Set, but safe from prototype modifications.

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages