Skip to content

Commit

Permalink
this.remove() and this.delete() with passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Apr 15, 2011
1 parent bb8d1b5 commit d603771
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ function walk (root, cb) {
}
state.node = x;
},
delete : function () {
delete state.parent.node[state.key];
},
remove : function () {
if (Array.isArray(state.parent.node)) {
state.parent.node.splice(state.key, 1);
}
else {
delete state.parent.node[state.key];
}
},
before : function (f) { modifiers.before = f },
after : function (f) { modifiers.after = f },
pre : function (f) { modifiers.pre = f },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "traverse",
"version" : "0.3.2",
"version" : "0.3.3",
"description" : "Traverse and transform objects by visiting every node on a recursive walk",
"author" : "James Halliday",
"license" : "MIT/X11",
Expand Down

0 comments on commit d603771

Please sign in to comment.