New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

circular

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

Tiny utility to safely stringify objects with circular references

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
decreased by-32.01%
Maintainers
1
Weekly downloads
 
Created
Source

Circular

Tiny utility to safely stringify objects with circular references.

Usage

Replace all circular references with the string [Circular];

var circular = require('circular');
var obj = {}; var child = {parent: obj}; obj.child = child;
var str = JSON.stringify(obj, circular());
// => {"child":{"parent":"[Circular]"}}

If you prefer you can pass an alternative string to use:

var str = JSON.stringify(obj, circular('#ref'));

Or a function that returns a string:

function ref(value){return '' + value};
var str = JSON.stringify(obj, circular(ref));

As of version 1.0.4 you can also pass an additional boolean that will convert function references to strings, useful for converting javascript modules to couchdb design documents.

var str = JSON.stringify(obj, circular(null, true));

License

Everything is MIT. Read the license if you feel inclined.

Keywords

FAQs

Package last updated on 26 Aug 2014

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