Socket
Book a DemoInstallSign in
Socket

set-tojson

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

set-tojson

ES7 Proposal: Set#toJSON https://github.com/DavidBruant/Map-Set.prototype.toJSON

latest
Source
npmnpm
Version
2.1.1
Version published
Weekly downloads
2K
88%
Maintainers
1
Weekly downloads
 
Created
Source

set-tojson Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

Rejected ESNext Proposal: Set#toJSON https://github.com/DavidBruant/Map-Set.prototype.toJSON

This polyfill is spec-compliant (based on the spec so far). It will work in every engine in which Set exists natively, or where it is polyfilled with the (es6-shim)es6-shim-url

Example

var setToJSON = require('set-tojson');
var assert = require('assert');
var items = ['a', 'b', 'c'];
var entries = [[1, 2], [3, 4]];

assert.deepEqual(setToJSON(new Set()), []);
assert.deepEqual(setToJSON(new Set(items)), items);
assert.deepEqual(setToJSON(new Map()), []);
assert.deepEqual(setToJSON(new Map(entries)), entries);
assert.deepEqual(setToJSON(''), []);
assert.deepEqual(setToJSON('abc'), ['a', 'b', 'c']);
assert.deepEqual(setToJSON([]), []);
assert.deepEqual(setToJSON(items), items);
assert.deepEqual(setToJSON(entries), entries);

setToJSON.shim();
assert.deepEqual(new Set(items).toJSON(), items);
assert.deepEqual(new Set().toJSON(), []);

Tests

Simply clone the repo, npm install, and run npm test

Keywords

Set

FAQs

Package last updated on 11 Jan 2022

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