Skip to content

Instantly share code, notes, and snippets.

@juliangruber
Created February 5, 2014 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliangruber/8819556 to your computer and use it in GitHub Desktop.
Save juliangruber/8819556 to your computer and use it in GitHub Desktop.
function values (ary) {
var i = 0;
return function (end, cb) {
if (i < ary.length) cb(true);
else cb(null, ary[i++])
}
}
function sync (read) {
read(null, function next (err, data) {
console.log(data);
if(!end) read(null, next)
})
}
function map(func) {
return function (read) {
return function (end, cb) {
read(end, function (end, data) {
cb(end, !end && func(data))
})
}
}
}
sink()(map(function (e) {
return e*10;
})(values([1,2,3])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment