Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

map-tojson

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

map-tojson

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

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34
decreased by-19.05%
Maintainers
1
Weekly downloads
 
Created
Source

map-tojson Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

Rejected ESNext Proposal: Map#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 Map exists natively, or where it is polyfilled with the (es6-shim)es6-shim-url

Example

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

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

mapToJSON.shim();
assert.deepEqual(new Map(entries).toJSON(), entries);
assert.deepEqual(new Map().toJSON(), []);

Tests

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

Keywords

FAQs

Package last updated on 13 Jan 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc