Created
October 10, 2010 23:36
-
-
Save pkrumins/619702 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkrumins@stackvm:~/projects/node-lazy$ cat tests/filter.js | |
var Lazy = require('lazy'); | |
var EventEmitter = require('events').EventEmitter; | |
function range(i, j) { | |
var r = []; | |
for (;i<j;i++) r.push(i); | |
return r; | |
} | |
var lazy = new Lazy; | |
lazy.filter(function(x) { return x > 5 }).map(function (x) { return x*2 }).take(2).forEach(function (x) { | |
console.log(x); | |
}); | |
range(0,10).forEach(function (x) { | |
lazy.emit('data', x); | |
}); | |
pkrumins@stackvm:~/projects/node-lazy$ node tests/filter.js | |
12 | |
14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment