destroy-circular

1.1.0 • Public • Published

destroy circular

Creates a copy of an object where all of the circular references are replaced by a string [Circular]. Useful for protecting against problems when stringifying an object when you don't have control over the stringifying. If you can stringify the object yourself, I recommend using circular instead.

install

npm install destroy-circular

usage

var dc = require('destroy-circular');
var obj = {}; var child = {parent: obj}; obj.child = child;
var stringifySafeObj = dc(obj);
console.log(stringifySafeObj); // -> { child: { parent: '[Circular]' } }

The returned object is a copy—the original is not mutated in any way.

license

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    3,276
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    3,276
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i destroy-circular

Weekly Downloads

3,276

Version

1.1.0

License

MIT

Last publish

Collaborators

  • jonpacker