Socket
Book a DemoInstallSign in
Socket

safeset

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safeset

Set, but safe from prototype modifications.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
0
Created
Source

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

Keywords

set

FAQs

Package last updated on 03 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts