-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpipe.js
More file actions
20 lines (17 loc) · 791 Bytes
/
pipe.js
File metadata and controls
20 lines (17 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"use strict";
var send = require("./send")
var reduce = require("reducible/reduce")
function pipe(input, output) {
/**
Takes reducible `input` and pipes it to the `output` (which is anything
that implements `send`). Note that first `end` or `error` from the piped
`input`-s will end an `output` causing subsequent `send`s return `reducers`
stopping other `input`-s. If you need to `pipe` all values form multiple
inputs do `pipe(merge(inputs), output)`, that way `output` will close only
once all inputs end. If you can't merge all the inputs up front you can
always pipe merged event. That way sending new inputs to that event will
automatically pipe all it's items.
**/
reduce(input, function pipeReducible(value) { send(output, value) })
}
module.exports = pipe