chainy/node_modules/traverse/examples/scrub.js
2020-01-26 21:03:32 +02:00

11 lines
242 B
JavaScript
Executable File

// scrub out circular references
var traverse = require('traverse');
var obj = { a : 1, b : 2, c : [ 3, 4 ] };
obj.c.push(obj);
var scrubbed = traverse(obj).map(function (x) {
if (this.circular) this.remove()
});
console.dir(scrubbed);