simplify streams, lint docs

This commit is contained in:
Leo Horie 2016-11-15 23:13:38 -05:00
parent a7f8018df9
commit 6ce2a384ec
20 changed files with 1271 additions and 2132 deletions

25
stream/scanMerge.js Normal file
View file

@ -0,0 +1,25 @@
"use strict"
var combine = require("./stream").combine
module.exports = function(tuples, seed) {
var streams = tuples.map(function(tuple) {
var stream = tuple[0]
if (stream._state.state === 0) stream(undefined)
return stream
})
var newStream = combine(function() {
var changed = arguments[arguments.length - 1]
streams.forEach(function(stream, idx) {
if (changed.indexOf(stream) > -1) {
seed = tuples[idx][1](seed, stream._state.value)
}
})
return seed
}, streams)
return newStream
}