Streamer library, which suggests opinionated stream definition / pattern and utilizes core library, that makes asynchronously recursive, pure function <3 possible without spaghetti code ninjas!
{ return function stream(next, stop) { fs.readdir(base, function(error, entries) { var entry // stop on error with error if (error) return stop(error) // Otherwise we yield each entry. while ((entry = entries.shift())) next(path.join(base, entry)) stop() }) } }
stats) { // if error, stop stream with error. if (error) return stop(error) // save path to find stat’s owner stats.path = path // We yield `stats` and stop the stream. next(stats) stop() }) } }
= 1 function onStop(error) { if (!open) return false if (error) open = 0 else open -- if (!open) stop(error) } source(function onStream(stream) { open ++ stream(function(value) { if (open) next(value) }, onStop) }, onStop) }
c) } function assemble(a) { return function stream(next, stop) { fs.readFile(a, function(e, content) { e ? stop(e) : next(context) }) } } function combine(b, c) { return map(function($) { return $ + b }, c) }