Permalink
Browse files

scrub example

  • Loading branch information...
1 parent 1148bc7 commit ec1fb18b494f1bcb6b1ce4a2a86dce6560ae746d @substack committed Jul 20, 2011
Showing with 10 additions and 0 deletions.
  1. +10 −0 examples/scrub.js
View
10 examples/scrub.js
@@ -0,0 +1,10 @@
+// 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);

0 comments on commit ec1fb18

Please sign in to comment.