Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

oh right and this example file

  • Loading branch information...
commit d98c125d9f9f17ca08260ed57ede2b1fac26da11 1 parent 86d71a9
@substack authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 examples/hash.js
View
23 examples/hash.js
@@ -0,0 +1,23 @@
+var Hash = require('traverse/hash');
+var sys = require('sys');
+
+var obj = Hash({ a : 1, b : 2 })
+ .map(function (v) { return v + 1 })
+ .update({ b : 30, c : 42 })
+ .filter(function (v) { return v % 2 == 0 })
+ .tap(function () {
+ var anyC = this.some(function (value, key) { return key == 'c' });
+ // or just this.keys.some, but anyways
+ console.log(anyC
+ ? "There's a C key this far."
+ : "There's no C key this far."
+ );
+ })
+ .items
+;
+
+/* Output:
+ There's a C key this far.
+ { a : 2, b : 30, c : 42 }
+*/
+console.log(sys.inspect(obj));
Please sign in to comment.
Something went wrong with that request. Please try again.