Socket
Socket
Sign inDemoInstall

circular-json-es6

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    circular-json-es6

circular JSON.stringify and JSON.parse, for environments with native ES6 Map


Version published
Weekly downloads
384K
decreased by-3.82%
Maintainers
1
Install size
24.3 kB
Created
Weekly downloads
 

Readme

Source

circular-json-es6

A replacement for JSON.stringify and JSON.parse that can handle circular references (persists reference structure).

This implementation requires environments with native ES6 Map support, but is decently faster than circular-json (see benchmark with npm run bench).

var CircularJSON = require('circular-json-es6')

var obj = {}
obj.a = obj

var clone = CircularJSON.parse(CircularJSON.stringify(obj))

clone.a === clone // -> true

NOTE

The default stringify method optimizes for cases where no circular reference is present by trying a plain JSON.stringify first. This means if no circular references are found in the data then it will not persist multiple (but non-circular) references to the same object.

If you want to enforce reference persistence, use CircularJSON.stringifyStrict instead.

FAQs

Last updated on 23 Jan 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc