Permalink
Browse files

function example

  • Loading branch information...
substack committed Jun 8, 2012
1 parent 5baad16 commit 19935f21d9503b200f287bfe727ad469a71f2d47
Showing with 22 additions and 0 deletions.
  1. +22 −0 example/fn.js
View
@@ -0,0 +1,22 @@
+var pathway = require('../');
+
+var xs = [
+ [ 'a', 1, 'b' ],
+ [ 'c', 2 ],
+ [ 'd', 3, 'e', 4, 'f' ],
+ [],
+ [ 'g', 5, 'h' ],
+];
+function True () { return true }
+function even (n) { return n % 2 === 0 }
+function odd (n) { return n % 2 === 1 }
+function doubleOdd (key, value) { return odd(key) && odd(value) }
+
+var odds = pathway(xs, [ True, odd ]);
+console.dir(odds); // [ 1, 2, 3, 4, 5 ]
+
+var evens = pathway(xs, [ True, even ]);
+console.dir(evens); // [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ]
+
+var doubleOdds = pathway(xs, [ True, doubleOdd ]);
+console.dir(doubleOdds); // [ 1, 3, 5 ]

0 comments on commit 19935f2

Please sign in to comment.