Skip to content

Instantly share code, notes, and snippets.

@Gozala
Last active August 29, 2015 14:00
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 Gozala/11159926 to your computer and use it in GitHub Desktop.
Save Gozala/11159926 to your computer and use it in GitHub Desktop.
function transform(transformer, input, buffer) {
var channel = new Channel(buffer)
transformer(input, channel.output)
return channel.input
}
var map = function(input, f, close) {
return transform(function(input, output) {
spawn(function*() {
while (var chunk = yield input.take(), take !== void(0)) {
yield output.put(f(chunk))
}
if (close)
output.close()
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment