scrub.js 242 B

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