scrub.js 253 B

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