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

circular-json-es6

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

circular-json-es6

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

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
383K
decreased by-1.6%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 23 Jan 2018

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