destroy-circular
Replace circular references in an object with a string
Last updated 12 years ago by jonpacker .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install destroy-circular 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.1.0                                ...           latest (12 years ago)

3 Versions

  • 1.1.0                                ...           12 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 12
Today 0
This Week 0
This Month 7
Last Day 0
Last Week 2
Last Month 4
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE