steampipes
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //########################################################################################################### |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -93,3 +93,3 @@ 'use strict'; | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @_classify_sink = ( transform ) -> | ||
@@ -99,3 +99,3 @@ // @_$drain transform unless transform[ @marks.validated ]? | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @_classify_transform = ( transform ) -> | ||
@@ -114,3 +114,3 @@ // R = do => | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @_flatten_transforms = ( transforms, R = null ) -> | ||
@@ -126,3 +126,3 @@ // R ?= [] | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @_new_duct = ( transforms ) -> | ||
@@ -155,3 +155,3 @@ // transforms = @_flatten_transforms transforms | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @_pull = ( transforms... ) -> | ||
@@ -239,3 +239,3 @@ // duct = @_new_duct transforms | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @pull = ( transforms... ) -> | ||
@@ -261,3 +261,3 @@ // duct = @_pull transforms... | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @_pull_async = ( duct ) -> | ||
@@ -281,3 +281,3 @@ // return duct unless duct.type is 'circuit' | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @_push = ( duct ) -> | ||
@@ -284,0 +284,0 @@ // ### Make `duct` available from the POV of the push source: ### |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //########################################################################################################### |
@@ -1,2 +0,1 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
(function() { | ||
@@ -61,4 +60,2 @@ 'use strict'; | ||
//........................................................................................................... | ||
require('cnd/lib/exception-handler'); | ||
provide_fifo = function() { | ||
@@ -262,3 +259,1 @@ //----------------------------------------------------------------------------------------------------------- | ||
}).call(this); | ||
//# sourceMappingURL=tail-stream.js.map |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -46,3 +46,3 @@ 'use strict'; | ||
/* TAINT his isn't a generator in the technical sense, but the code from | ||
https://github.com/pull-stream/pull-stream/blob/master/sources/infinite.js expanded upon. */ | ||
https://github.com/pull-stream/pull-stream/blob/master/sources/infinite.js expanded upon. */ | ||
$random = function(n, seed, delta) { | ||
@@ -49,0 +49,0 @@ var rnd; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //########################################################################################################### |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //########################################################################################################### |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -484,7 +484,7 @@ 'use strict'; | ||
/* A mainstream and a bystream are created from lists of values using | ||
`SP.new_random_async_value_source()`. Values from both streams are marked up for their respective source. | ||
After being funnelled together using `SP.$wye()`, the result is a POD whose keys are the source names | ||
and whose values are lists of the values in the order they were seen. The expected result is that the | ||
ordering of each stream is preserved, no values get lost, and that relative ordering of values in the | ||
mainstream and the bystream is arbitrary. */ | ||
`SP.new_random_async_value_source()`. Values from both streams are marked up for their respective source. | ||
After being funnelled together using `SP.$wye()`, the result is a POD whose keys are the source names | ||
and whose values are lists of the values in the order they were seen. The expected result is that the | ||
ordering of each stream is preserved, no values get lost, and that relative ordering of values in the | ||
mainstream and the bystream is arbitrary. */ | ||
var R, error, i, len, matcher, probe, probes_and_matchers; | ||
@@ -491,0 +491,0 @@ probes_and_matchers = [ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -40,3 +40,3 @@ 'use strict'; | ||
/* Moving window over data items in stream. Turns stream of values into stream of | ||
lists each `width` elements long. */ | ||
lists each `width` elements long. */ | ||
var _, buffer, defaults, fallback, had_value, last; | ||
@@ -95,6 +95,6 @@ defaults = { | ||
/* Turns stream of values into stream of lists of values, each `( 2 * delta ) + 1` elements long; | ||
unlike `$window()`, will send exactly as many lists as there are values in the stream. Default | ||
is `delta: 1`, i.e. you get to see lists `[ prv, d, nxt, ]` where `prv` is the previous value | ||
(or the fallback which itself defaults to `null`), `d` is the current value, and `nxt` is the | ||
upcoming value (or `fallback` in case the stream will end after this value). */ | ||
unlike `$window()`, will send exactly as many lists as there are values in the stream. Default | ||
is `delta: 1`, i.e. you get to see lists `[ prv, d, nxt, ]` where `prv` is the previous value | ||
(or the fallback which itself defaults to `null`), `d` is the current value, and `nxt` is the | ||
upcoming value (or `fallback` in case the stream will end after this value). */ | ||
var center, defaults, delta, fallback, pipeline; | ||
@@ -101,0 +101,0 @@ defaults = { |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -43,4 +43,4 @@ 'use strict'; | ||
/* Given a `bystream`, send a data down both the mainstream and the bystream. This allows e.g. to log all | ||
events to a file sink while continuing to process the same data in the mainline. **NB** that in | ||
contradistinction to `pull-tee`, you can only divert to a single by-stream with each call to `PS.$tee` */ | ||
events to a file sink while continuing to process the same data in the mainline. **NB** that in | ||
contradistinction to `pull-tee`, you can only divert to a single by-stream with each call to `PS.$tee` */ | ||
return (require('pull-tee'))(bystream); | ||
@@ -52,3 +52,3 @@ }; | ||
/* Given a `filter` function and a `bystream`, send only data `d` for which `filter d` returns true down | ||
the bystream. No data will be taken out of the mainstream. */ | ||
the bystream. No data will be taken out of the mainstream. */ | ||
return this._$tee_without_filter(this.pull(this.$filter(filter), bystream)); | ||
@@ -60,3 +60,3 @@ }; | ||
/* Given a `filter` function and a `bystream`, send all data `d` either down the bystream if `filter d` | ||
returns true, or down the mainstream otherwise, causing a disjunct bifurcation of the data stream. */ | ||
returns true, or down the mainstream otherwise, causing a disjunct bifurcation of the data stream. */ | ||
var byline, pipeline; | ||
@@ -132,5 +132,5 @@ byline = []; | ||
/* Given a `test` function (which accepts a single argument) and a `transform`, make it so that whenever | ||
`test d` returns `true`, data `d` will be taken out of the stream and 'jump over' the transform, as it | ||
were. Downstream transforms will still receive all data items, including the leapfrogging ones, but the | ||
stream as it is visible to the `transform` will be thinned out. */ | ||
`test d` returns `true`, data `d` will be taken out of the stream and 'jump over' the transform, as it | ||
were. Downstream transforms will still receive all data items, including the leapfrogging ones, but the | ||
stream as it is visible to the `transform` will be thinned out. */ | ||
//......................................................................................................... | ||
@@ -137,0 +137,0 @@ last = Symbol('last'); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -231,6 +231,6 @@ 'use strict'; | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @node_stream_from_source = ( source ) -> TO_NODE_STREAM.source source | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// @node_stream_from_sink = ( sink ) -> | ||
@@ -237,0 +237,0 @@ // ### TAINT consider to abandon all sinks except `$drain()` and use throughs with writers instead ### |
@@ -1,5 +0,5 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
'use strict'; | ||
var CND, PD, alert, badge, debug, echo, help, info, log, rpr, urge, warn, whisper; | ||
var CND, alert, badge, debug, echo, help, info, log, rpr, urge, warn, whisper; | ||
@@ -32,7 +32,7 @@ //########################################################################################################### | ||
//........................................................................................................... | ||
PD = require('pipedreams'); | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.adapt_ps_transform = function(ps_transform) { | ||
var pipeline, ps_source, send; | ||
var PD, pipeline, ps_source, send; | ||
PD = require('pipedreams'); | ||
ps_source = PD.new_push_source(); | ||
@@ -39,0 +39,0 @@ send = null; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -51,2 +51,3 @@ 'use strict'; | ||
isa_pusher: Symbol('isa_pusher'), // Marks a push source as such | ||
isa_wye: Symbol('isa_wye'), // Marks an intermediate source | ||
send_last: Symbol('send_last'), // Marks transforms expecting a certain value before EOS | ||
@@ -65,3 +66,3 @@ async: Symbol('async') // Marks transforms as asynchronous (experimental) | ||
if ((arity = transform.length) !== 2) { | ||
throw new Error(`µ20123 transform arity ${arity} not implemented`); | ||
throw new Error(`^steampipes/pullremit@7000^ transform arity ${arity} not implemented`); | ||
} | ||
@@ -81,8 +82,8 @@ if ((sink = transform.sink) == null) { | ||
var R, arity, done, resolve, send, sink; | ||
/* TAINT incomplete implementation: surround, leapfrog arguments missing */ | ||
if (arguments.length !== 1) { | ||
/* TAINT incomplete implementation: surround, leapfrog arguments missing */ | ||
throw new Error("µ77644 modifications not yet implemented"); | ||
throw new Error("^steampipes/pullremit@7001^ modifications not yet implemented"); | ||
} | ||
if ((arity = transform.length) !== 3) { | ||
throw new Error(`µ77644 transform arity ${arity} not implemented`); | ||
throw new Error(`^steampipes/pullremit@7002^ transform arity ${arity} not implemented`); | ||
} | ||
@@ -132,2 +133,7 @@ resolve = null; | ||
} | ||
if (transform[this.marks.isa_wye] != null) { | ||
return { | ||
type: 'wye' | ||
}; | ||
} | ||
if (transform[Symbol.iterator] != null) { | ||
@@ -152,3 +158,3 @@ return { | ||
} | ||
throw new Error(`µ44521 expected an iterable, a function, a generator function or a sink, got a ${type}`); | ||
throw new Error(`^steampipes/pullremit@7003^ expected an iterable, a function, a generator function or a sink, got a ${type}`); | ||
})(); | ||
@@ -226,7 +232,12 @@ R.mode = transform[this.marks.async] != null ? 'async' : 'sync'; | ||
default: | ||
throw new Error(`µ44521 illegal duct configuration ${rpr(key)}`); | ||
throw new Error(`^steampipes/pullremit@7004^ illegal duct configuration ${rpr(key)}`); | ||
} | ||
for (idx = i = 1, ref2 = blurbs.length - 1; i < ref2; idx = i += +1) { | ||
if ((b = blurbs[idx]).type !== 'through') { | ||
throw new Error(`µ44522 illegal duct configuration at transform index ${idx}: ${rpr(b)}`); | ||
switch ((b = blurbs[idx]).type) { | ||
case 'through': | ||
case 'wye': | ||
null; | ||
break; | ||
default: | ||
throw new Error(`^steampipes/pullremit@7005^ illegal duct configuration at transform index ${idx}: ${rpr(b)}`); | ||
} | ||
@@ -245,6 +256,6 @@ } | ||
if (duct.last.type === 'source') { | ||
throw new Error("µ77764 source as last transform not yet supported"); | ||
throw new Error("^steampipes/pullremit@7006^ source as last transform not yet supported"); | ||
} | ||
if (duct.first.type === 'sink') { | ||
throw new Error("µ77765 sink as first transform not yet supported"); | ||
throw new Error("^steampipes/pullremit@7007^ sink as first transform not yet supported"); | ||
} | ||
@@ -386,9 +397,87 @@ //......................................................................................................... | ||
//----------------------------------------------------------------------------------------------------------- | ||
this._integrate_wye = function(transforms, wye_idx) { | ||
var A_has_ended, B_has_ended, duct_A, duct_B, duct_C, end_source_C, last, pipeline_A, pipeline_B, pipeline_C, source_A, source_B, source_C; | ||
last = Symbol('last'); | ||
//......................................................................................................... | ||
source_A = probe_A; | ||
A_has_ended = false; | ||
B_has_ended = false; | ||
pipeline_A = []; | ||
pipeline_A.push(source_A); | ||
pipeline_A.push($watch(function(d) { | ||
return help('A', jr(d)); | ||
})); | ||
pipeline_A.push($({last}, function(d, send) { | ||
if (d === last) { | ||
A_has_ended = true; | ||
return end_source_C(); | ||
} | ||
return source_C.send(d); | ||
})); | ||
pipeline_A.push($drain(function() { | ||
return whisper('A'); | ||
})); | ||
//......................................................................................................... | ||
source_B = probe_B; | ||
pipeline_B = []; | ||
pipeline_B.push(source_B); | ||
pipeline_B.push($watch(function(d) { | ||
return urge('B', jr(d)); | ||
})); | ||
pipeline_B.push($({last}, function(d, send) { | ||
if (d === last) { | ||
B_has_ended = true; | ||
return end_source_C(); | ||
} | ||
return source_C.send(d); | ||
})); | ||
pipeline_B.push($drain(function() { | ||
return whisper('B'); | ||
})); | ||
//......................................................................................................... | ||
source_C = SP.new_push_source(); | ||
pipeline_C = []; | ||
pipeline_C.push(source_C); | ||
pipeline_C.push($watch(function(d) { | ||
return info('C', jr(d)); | ||
})); | ||
pipeline_C.push($drain(function(Σ) { | ||
whisper('C', jr(Σ)); | ||
return resolve(Σ.join('')); | ||
})); | ||
//......................................................................................................... | ||
end_source_C = function() { | ||
if (!(A_has_ended && B_has_ended)) { | ||
return; | ||
} | ||
return source_C.end(); | ||
}; | ||
//......................................................................................................... | ||
// pipeline_A.push wye | ||
duct_C = SP.pull(...pipeline_C); | ||
duct_A = SP.pull(...pipeline_A); | ||
return duct_B = SP.pull(...pipeline_B); | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this._integrate_wyes = function(...transforms) { | ||
debug('^776665^', transforms); | ||
// for transform, wye_idx in transforms | ||
// if transform[ @marks.isa_wye ] | ||
// return @_integrate_wye transforms, wye_idx | ||
return null; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.pull = function(...transforms) { | ||
var d, drain, duct, first_bucket, on_end, ref; | ||
if ((duct = this._integrate_wyes(...transforms)) != null) { | ||
return duct; | ||
} | ||
duct = this._pull(...transforms); | ||
//......................................................................................................... | ||
if (isa.function(duct.transforms[0].start)) { | ||
duct.transforms[0].start(); | ||
} | ||
if (duct.type !== 'circuit') { | ||
// #......................................................................................................... | ||
// ### TAINT `await` makes this an async method; is that a problem? ### | ||
// if isa.function duct.transforms[ 0 ].start then duct.transforms[ 0 ].start() | ||
// else if isa.asyncfunction duct.transforms[ 0 ].start then await duct.transforms[ 0 ].start() | ||
@@ -395,0 +484,0 @@ //......................................................................................................... |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,5 +0,5 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
'use strict'; | ||
var CND, assign, badge, debug, echo, help, info, isa, jr, rpr, type_of, urge, validate, warn, whisper; | ||
var CND, assign, badge, debug, defaults, echo, help, info, isa, jr, rpr, type_of, urge, validate, warn, whisper; | ||
@@ -33,3 +33,3 @@ //########################################################################################################### | ||
//........................................................................................................... | ||
({isa, validate, type_of} = require('./types')); | ||
({isa, validate, defaults, type_of} = require('./types')); | ||
@@ -85,4 +85,22 @@ //----------------------------------------------------------------------------------------------------------- | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.new_wye = function(settings, source) { | ||
var arity, ref; | ||
switch (arity = arguments.length) { | ||
case 1: | ||
[settings, source] = [null, settings]; | ||
break; | ||
case 2: | ||
null; | ||
break; | ||
default: | ||
throw new Error(`µ44578 expected 1 or 2 arguments, got ${arity}`); | ||
} | ||
settings = {...defaults.steampipes_new_wye_settings, ...settings}; | ||
validate.steampipes_new_wye_settings(settings); | ||
return {[ref = this.marks.isa_wye]: ref, settings, source}; | ||
}; | ||
}).call(this); | ||
//# sourceMappingURL=sources.js.map |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -116,4 +116,4 @@ 'use strict'; | ||
/* If any `surround` feature is called for, wrap all surround values so that we can safely | ||
distinguish between them and ordinary stream values; this is necessary to prevent them from leaking | ||
into the regular stream outside the `$watch` transform: */ | ||
distinguish between them and ordinary stream values; this is necessary to prevent them from leaking | ||
into the regular stream outside the `$watch` transform: */ | ||
var arity, key, take_second, value; | ||
@@ -120,0 +120,0 @@ switch (arity = arguments.length) { |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -783,21 +783,21 @@ //########################################################################################################### | ||
* The proper way to end a push source is to call `source.end()`; `send.end()` is largely equivalent. | ||
[ probe, matcher, error, ] = [["what","a","lot","of","little","bottles","stop"],["what","a","lot","of","little","bottles"],null] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = [] | ||
drainer = -> help 'ok'; resolve R | ||
source = SP.new_push_source() | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push $ ( d, send ) -> if d is 'stop' then send.end() else send d | ||
pipeline.push SP.$collect { collector: R, } | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$drain drainer | ||
pull pipeline... | ||
for word in probe | ||
source.send word | ||
[ probe, matcher, error, ] = [["what","a","lot","of","little","bottles","stop"],["what","a","lot","of","little","bottles"],null] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = [] | ||
drainer = -> help 'ok'; resolve R | ||
source = SP.new_push_source() | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push $ ( d, send ) -> if d is 'stop' then send.end() else send d | ||
pipeline.push SP.$collect { collector: R, } | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$drain drainer | ||
pull pipeline... | ||
for word in probe | ||
source.send word | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
@@ -807,76 +807,100 @@ #----------------------------------------------------------------------------------------------------------- | ||
* A stream may be ended by using an `$end_if()` (alternatively, `$continue_if()`) transform. | ||
[ probe, matcher, error, ] = [["what","a","lot","of","little","bottles","stop"],["what","a","lot","of","little","bottles"],null] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = [] | ||
drainer = -> help 'ok'; resolve R | ||
source = SP.new_push_source() | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$end_if ( d ) -> d is 'stop' | ||
pipeline.push SP.$collect { collector: R, } | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$drain drainer | ||
pull pipeline... | ||
for word in probe | ||
source.send word | ||
[ probe, matcher, error, ] = [["what","a","lot","of","little","bottles","stop"],["what","a","lot","of","little","bottles"],null] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = [] | ||
drainer = -> help 'ok'; resolve R | ||
source = SP.new_push_source() | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$end_if ( d ) -> d is 'stop' | ||
pipeline.push SP.$collect { collector: R, } | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$drain drainer | ||
pull pipeline... | ||
for word in probe | ||
source.send word | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#----------------------------------------------------------------------------------------------------------- | ||
@[ "wrap FS object for sink" ] = ( T, done ) -> | ||
output_path = '/tmp/pipestreams-test-output.txt' | ||
output_stream = FS.createWriteStream output_path | ||
sink = SP.write_to_nodejs_stream output_stream #, ( error ) -> debug '37783', error | ||
pipeline = [] | ||
pipeline.push $values Array.from 'abcdef' | ||
pipeline.push SP.$show() | ||
pipeline.push sink | ||
pull pipeline... | ||
output_stream.on 'finish', => | ||
T.ok CND.equals 'abcdef', read output_path | ||
done() | ||
output_path = '/tmp/pipestreams-test-output.txt' | ||
output_stream = FS.createWriteStream output_path | ||
sink = SP.write_to_nodejs_stream output_stream #, ( error ) -> debug '37783', error | ||
pipeline = [] | ||
pipeline.push $values Array.from 'abcdef' | ||
pipeline.push SP.$show() | ||
pipeline.push sink | ||
pull pipeline... | ||
output_stream.on 'finish', => | ||
T.ok CND.equals 'abcdef', read output_path | ||
done() | ||
#----------------------------------------------------------------------------------------------------------- | ||
@[ "function as pull-stream source" ] = ( T, done ) -> | ||
random = ( n ) => | ||
return ( end, callback ) => | ||
if end? | ||
debug '40998', rpr callback | ||
debug '40998', rpr end | ||
return callback end | ||
#only read n times, then stop. | ||
n += -1 | ||
if n < 0 | ||
return callback true | ||
callback null, Math.random() | ||
return null | ||
#......................................................................................................... | ||
pipeline = [] | ||
Ø = ( x ) => pipeline.push x | ||
Ø random 10 | ||
random = ( n ) => | ||
return ( end, callback ) => | ||
if end? | ||
debug '40998', rpr callback | ||
debug '40998', rpr end | ||
return callback end | ||
#only read n times, then stop. | ||
n += -1 | ||
if n < 0 | ||
return callback true | ||
callback null, Math.random() | ||
return null | ||
#......................................................................................................... | ||
pipeline = [] | ||
Ø = ( x ) => pipeline.push x | ||
Ø random 10 | ||
* Ø random 3 | ||
Ø SP.$collect() | ||
Ø $ { last: null, }, ( data, send ) -> | ||
if data? | ||
T.ok data.length is 10 | ||
debug data | ||
send data | ||
else | ||
T.succeed "function works as pull-stream source" | ||
done() | ||
send null | ||
Ø SP.$show() | ||
Ø SP.$drain() | ||
#......................................................................................................... | ||
SP.pull pipeline... | ||
return null | ||
Ø SP.$collect() | ||
Ø $ { last: null, }, ( data, send ) -> | ||
if data? | ||
T.ok data.length is 10 | ||
debug data | ||
send data | ||
else | ||
T.succeed "function works as pull-stream source" | ||
done() | ||
send null | ||
Ø SP.$show() | ||
Ø SP.$drain() | ||
#......................................................................................................... | ||
SP.pull pipeline... | ||
return null | ||
#----------------------------------------------------------------------------------------------------------- | ||
@[ "$surround" ] = ( T, done ) -> | ||
[ probe, matcher, error, ] = [null,"first[(1),(2),(3),(4),(5)]last",null] | ||
await T.perform probe, matcher, error, -> | ||
return new Promise ( resolve, reject ) -> | ||
[ probe, matcher, error, ] = [null,"first[(1),(2),(3),(4),(5)]last",null] | ||
await T.perform probe, matcher, error, -> | ||
return new Promise ( resolve, reject ) -> | ||
R = null | ||
drainer = -> help 'ok'; resolve R | ||
pipeline = [] | ||
pipeline.push SP.new_value_source [ 1 .. 5 ] | ||
#......................................................................................................... | ||
pipeline.push SP.$surround { first: '[', last: ']', before: '(', between: ',', after: ')' } | ||
pipeline.push SP.$surround { first: 'first', last: 'last', } | ||
* pipeline.push SP.$surround { first: 'first', last: 'last', before: 'before', between: 'between', after: 'after' } | ||
* pipeline.push SP.$surround { first: '[', last: ']', } | ||
#......................................................................................................... | ||
pipeline.push SP.$collect() | ||
pipeline.push $ ( d, send ) -> send ( x.toString() for x in d ).join '' | ||
pipeline.push SP.$watch ( d ) -> R = d | ||
pipeline.push SP.$drain drainer | ||
SP.pull pipeline... | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#----------------------------------------------------------------------------------------------------------- | ||
@[ "$surround async" ] = ( T, done ) -> | ||
[ probe, matcher, error, ] = [null,"[first|1|2|3|4|5|last]",null] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = null | ||
@@ -887,6 +911,8 @@ drainer = -> help 'ok'; resolve R | ||
#......................................................................................................... | ||
pipeline.push SP.$surround { first: '[', last: ']', before: '(', between: ',', after: ')' } | ||
pipeline.push SP.$surround { first: 'first', last: 'last', } | ||
* pipeline.push SP.$surround { first: 'first', last: 'last', before: 'before', between: 'between', after: 'after' } | ||
* pipeline.push SP.$surround { first: '[', last: ']', } | ||
pipeline.push $async { first: '[', last: ']', between: '|', }, ( d, send, done ) => | ||
defer -> | ||
* debug '22922', jr d | ||
send d | ||
done() | ||
#......................................................................................................... | ||
@@ -899,73 +925,47 @@ pipeline.push SP.$collect() | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#----------------------------------------------------------------------------------------------------------- | ||
@[ "$surround async" ] = ( T, done ) -> | ||
[ probe, matcher, error, ] = [null,"[first|1|2|3|4|5|last]",null] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = null | ||
drainer = -> help 'ok'; resolve R | ||
pipeline = [] | ||
pipeline.push SP.new_value_source [ 1 .. 5 ] | ||
#......................................................................................................... | ||
pipeline.push SP.$surround { first: 'first', last: 'last', } | ||
pipeline.push $async { first: '[', last: ']', between: '|', }, ( d, send, done ) => | ||
defer -> | ||
* debug '22922', jr d | ||
send d | ||
done() | ||
#......................................................................................................... | ||
pipeline.push SP.$collect() | ||
pipeline.push $ ( d, send ) -> send ( x.toString() for x in d ).join '' | ||
pipeline.push SP.$watch ( d ) -> R = d | ||
pipeline.push SP.$drain drainer | ||
SP.pull pipeline... | ||
done() | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#----------------------------------------------------------------------------------------------------------- | ||
@[ "end random async source" ] = ( T, done ) -> | ||
[ probe, matcher, error, ] = [["what","a","lot","of","little","bottles"],["what","a","lot","of","little","bottles"],null] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = [] | ||
drainer = -> help 'ok'; resolve R | ||
source = SP.new_random_async_value_source probe | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$collect { collector: R, } | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$drain drainer | ||
pull pipeline... | ||
[ probe, matcher, error, ] = [["what","a","lot","of","little","bottles"],["what","a","lot","of","little","bottles"],null] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = [] | ||
drainer = -> help 'ok'; resolve R | ||
source = SP.new_random_async_value_source probe | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$collect { collector: R, } | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$drain drainer | ||
pull pipeline... | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#----------------------------------------------------------------------------------------------------------- | ||
@[ "read file chunks" ] = ( T, done ) -> | ||
[ probe, matcher, error, ] = [ __filename, null, null, ] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = [] | ||
drainer = -> help 'ok'; resolve null | ||
source = SP.read_chunks_from_file probe, 50 | ||
count = 0 | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push $ ( d, send ) -> send d.toString 'utf-8' | ||
pipeline.push SP.$watch -> | ||
count += +1 | ||
source.end() if count > 3 | ||
pipeline.push SP.$collect { collector: R, } | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$drain drainer | ||
pull pipeline... | ||
[ probe, matcher, error, ] = [ __filename, null, null, ] | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
R = [] | ||
drainer = -> help 'ok'; resolve null | ||
source = SP.read_chunks_from_file probe, 50 | ||
count = 0 | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push $ ( d, send ) -> send d.toString 'utf-8' | ||
pipeline.push SP.$watch -> | ||
count += +1 | ||
source.end() if count > 3 | ||
pipeline.push SP.$collect { collector: R, } | ||
pipeline.push SP.$watch ( d ) -> info xrpr d | ||
pipeline.push SP.$drain drainer | ||
pull pipeline... | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
@@ -975,55 +975,55 @@ #----------------------------------------------------------------------------------------------------------- | ||
* through = require 'pull-through' | ||
probes_and_matchers = [ | ||
[[false,[1,2,3,null,5]],[1,1,1,2,2,2,3,3,3,null,null,null,5,5,5],null] | ||
[[true,[1,2,3,null,5]],[1,1,1,2,2,2,3,3,3,null,null,null,5,5,5],null] | ||
[[false,[1,2,3,"stop",25,30]],[1,1,1,2,2,2,3,3,3],null] | ||
[[true,[1,2,3,"stop",25,30]],[1,1,1,2,2,2,3,3,3],null] | ||
[[false,[1,2,3,null,"stop",25,30]],[1,1,1,2,2,2,3,3,3,null,null,null],null] | ||
[[true,[1,2,3,null,"stop",25,30]],[1,1,1,2,2,2,3,3,3,null,null,null],null] | ||
[[false,[1,2,3,undefined,"stop",25,30]],[1,1,1,2,2,2,3,3,3,undefined,undefined,undefined,],null] | ||
[[true,[1,2,3,undefined,"stop",25,30]],[1,1,1,2,2,2,3,3,3,undefined,undefined,undefined,],null] | ||
[[false,["stop",25,30]],[],null] | ||
[[true,["stop",25,30]],[],null] | ||
] | ||
#......................................................................................................... | ||
aborting_map = ( use_defer, mapper ) -> | ||
react = ( handler, data ) -> | ||
if data is 'stop' then handler true | ||
else handler null, mapper data | ||
probes_and_matchers = [ | ||
[[false,[1,2,3,null,5]],[1,1,1,2,2,2,3,3,3,null,null,null,5,5,5],null] | ||
[[true,[1,2,3,null,5]],[1,1,1,2,2,2,3,3,3,null,null,null,5,5,5],null] | ||
[[false,[1,2,3,"stop",25,30]],[1,1,1,2,2,2,3,3,3],null] | ||
[[true,[1,2,3,"stop",25,30]],[1,1,1,2,2,2,3,3,3],null] | ||
[[false,[1,2,3,null,"stop",25,30]],[1,1,1,2,2,2,3,3,3,null,null,null],null] | ||
[[true,[1,2,3,null,"stop",25,30]],[1,1,1,2,2,2,3,3,3,null,null,null],null] | ||
[[false,[1,2,3,undefined,"stop",25,30]],[1,1,1,2,2,2,3,3,3,undefined,undefined,undefined,],null] | ||
[[true,[1,2,3,undefined,"stop",25,30]],[1,1,1,2,2,2,3,3,3,undefined,undefined,undefined,],null] | ||
[[false,["stop",25,30]],[],null] | ||
[[true,["stop",25,30]],[],null] | ||
] | ||
#......................................................................................................... | ||
aborting_map = ( use_defer, mapper ) -> | ||
react = ( handler, data ) -> | ||
if data is 'stop' then handler true | ||
else handler null, mapper data | ||
* a sink function: accept a source... | ||
return ( read ) -> | ||
return ( read ) -> | ||
* ...but return another source! | ||
return ( abort, handler ) -> | ||
read abort, ( error, data ) -> | ||
return ( abort, handler ) -> | ||
read abort, ( error, data ) -> | ||
* if the stream has ended, pass that on. | ||
return handler error if error | ||
if use_defer then defer -> react handler, data | ||
else react handler, data | ||
return handler error if error | ||
if use_defer then defer -> react handler, data | ||
else react handler, data | ||
return null | ||
return null | ||
return null | ||
return null | ||
#......................................................................................................... | ||
for [ probe, matcher, error, ] in probes_and_matchers | ||
await T.perform probe, matcher, error, -> new Promise ( resolve ) -> | ||
#..................................................................................................... | ||
[ use_defer | ||
values ] = probe | ||
source = SP.new_value_source values | ||
collector = [] | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push aborting_map use_defer, ( d ) -> info '22398-1', xrpr d; return d | ||
pipeline.push SP.$ ( d, send ) -> info '22398-2', xrpr d; collector.push d; send d | ||
pipeline.push SP.$ ( d, send ) -> info '22398-3', xrpr d; collector.push d; send d | ||
pipeline.push SP.$ ( d, send ) -> info '22398-4', xrpr d; collector.push d; send d | ||
#......................................................................................................... | ||
for [ probe, matcher, error, ] in probes_and_matchers | ||
await T.perform probe, matcher, error, -> new Promise ( resolve ) -> | ||
#..................................................................................................... | ||
[ use_defer | ||
values ] = probe | ||
source = SP.new_value_source values | ||
collector = [] | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push aborting_map use_defer, ( d ) -> info '22398-1', xrpr d; return d | ||
pipeline.push SP.$ ( d, send ) -> info '22398-2', xrpr d; collector.push d; send d | ||
pipeline.push SP.$ ( d, send ) -> info '22398-3', xrpr d; collector.push d; send d | ||
pipeline.push SP.$ ( d, send ) -> info '22398-4', xrpr d; collector.push d; send d | ||
* pipeline.push SP.$map ( d ) -> info '22398-2', xrpr d; collector.push d; return d | ||
* pipeline.push SP.$map ( d ) -> info '22398-3', xrpr d; collector.push d; return d | ||
* pipeline.push SP.$map ( d ) -> info '22398-4', xrpr d; collector.push d; return d | ||
pipeline.push SP.$drain -> | ||
help '44998', xrpr collector | ||
resolve collector | ||
pull pipeline... | ||
#......................................................................................................... | ||
done() | ||
return null | ||
pipeline.push SP.$drain -> | ||
help '44998', xrpr collector | ||
resolve collector | ||
pull pipeline... | ||
#......................................................................................................... | ||
done() | ||
return null | ||
@@ -1033,56 +1033,56 @@ #----------------------------------------------------------------------------------------------------------- | ||
* through = require 'pull-through' | ||
probes_and_matchers = [ | ||
[["a"],[{"is_first":true,"is_last":true,"d":"a"}],null] | ||
[[],[],null] | ||
[[1,2,3],[{"is_first":true,"is_last":false,"d":1},{"is_first":false,"is_last":false,"d":2},{"is_first":false,"is_last":true,"d":3}],null] | ||
[["a","b"],[{"is_first":true,"is_last":false,"d":"a"},{"is_first":false,"is_last":true,"d":"b"}],null] | ||
] | ||
#......................................................................................................... | ||
collector = [] | ||
for [ probe, matcher, error, ] in probes_and_matchers | ||
await T.perform probe, matcher, error, -> new Promise ( resolve ) -> | ||
#..................................................................................................... | ||
source = SP.new_value_source probe | ||
collector = [] | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push SP.$mark_position() | ||
pipeline.push SP.$collect { collector, } | ||
pipeline.push SP.$drain -> resolve collector | ||
pull pipeline... | ||
#......................................................................................................... | ||
done() | ||
return null | ||
probes_and_matchers = [ | ||
[["a"],[{"is_first":true,"is_last":true,"d":"a"}],null] | ||
[[],[],null] | ||
[[1,2,3],[{"is_first":true,"is_last":false,"d":1},{"is_first":false,"is_last":false,"d":2},{"is_first":false,"is_last":true,"d":3}],null] | ||
[["a","b"],[{"is_first":true,"is_last":false,"d":"a"},{"is_first":false,"is_last":true,"d":"b"}],null] | ||
] | ||
#......................................................................................................... | ||
collector = [] | ||
for [ probe, matcher, error, ] in probes_and_matchers | ||
await T.perform probe, matcher, error, -> new Promise ( resolve ) -> | ||
#..................................................................................................... | ||
source = SP.new_value_source probe | ||
collector = [] | ||
pipeline = [] | ||
pipeline.push source | ||
pipeline.push SP.$mark_position() | ||
pipeline.push SP.$collect { collector, } | ||
pipeline.push SP.$drain -> resolve collector | ||
pull pipeline... | ||
#......................................................................................................... | ||
done() | ||
return null | ||
#----------------------------------------------------------------------------------------------------------- | ||
@[ "$scramble" ] = ( T, done ) -> | ||
probes_and_matchers = [ | ||
[[[],0.5,42],[],null] | ||
[[[1],0.5,42],[1],null] | ||
[[[1,2],0.5,42],[1,2],null] | ||
[[[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],0.5,42],[1,4,2,5,3,6,7,14,12,9,13,8,16,10,15,11,17,18,19,20,21,22,24,26,23,25,27,28,29,30,32,31,33,34,35,37,36,38,39,40],null] | ||
[[[1,2,3,4,5,6,7,8,9,10],1,2],[9,2,7,5,8,4,10,1,3,6],null] | ||
[[[1,2,3,4,5,6,7,8,9,10],0.1,2],[1,2,3,4,5,6,7,8,9,10],null] | ||
[[[1,2,3,4,5,6,7,8,9,10],0,2],[1,2,3,4,5,6,7,8,9,10],null] | ||
] | ||
#......................................................................................................... | ||
for [ probe, matcher, error, ] in probes_and_matchers | ||
#....................................................................................................... | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
[ values | ||
p | ||
seed ] = probe | ||
cache = {} | ||
collector = [] | ||
pipeline = [] | ||
pipeline.push SP.new_value_source values | ||
pipeline.push SP.$scramble p, { seed, } | ||
pipeline.push SP.$collect { collector, } | ||
pipeline.push SP.$drain -> resolve collector | ||
SP.pull pipeline... | ||
#..................................................................................................... | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
probes_and_matchers = [ | ||
[[[],0.5,42],[],null] | ||
[[[1],0.5,42],[1],null] | ||
[[[1,2],0.5,42],[1,2],null] | ||
[[[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],0.5,42],[1,4,2,5,3,6,7,14,12,9,13,8,16,10,15,11,17,18,19,20,21,22,24,26,23,25,27,28,29,30,32,31,33,34,35,37,36,38,39,40],null] | ||
[[[1,2,3,4,5,6,7,8,9,10],1,2],[9,2,7,5,8,4,10,1,3,6],null] | ||
[[[1,2,3,4,5,6,7,8,9,10],0.1,2],[1,2,3,4,5,6,7,8,9,10],null] | ||
[[[1,2,3,4,5,6,7,8,9,10],0,2],[1,2,3,4,5,6,7,8,9,10],null] | ||
] | ||
#......................................................................................................... | ||
for [ probe, matcher, error, ] in probes_and_matchers | ||
#....................................................................................................... | ||
await T.perform probe, matcher, error, -> return new Promise ( resolve, reject ) -> | ||
[ values | ||
p | ||
seed ] = probe | ||
cache = {} | ||
collector = [] | ||
pipeline = [] | ||
pipeline.push SP.new_value_source values | ||
pipeline.push SP.$scramble p, { seed, } | ||
pipeline.push SP.$collect { collector, } | ||
pipeline.push SP.$drain -> resolve collector | ||
SP.pull pipeline... | ||
#..................................................................................................... | ||
return null | ||
#......................................................................................................... | ||
done() | ||
return null | ||
*/ | ||
@@ -1089,0 +1089,0 @@ //########################################################################################################### |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ //########################################################################################################### |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -151,3 +151,3 @@ 'use strict'; | ||
path = __filename; | ||
probes_and_matchers = [[["A text that\nextends over several lines\näöüÄÖÜß", '\n'], null, null], [["A text that\nextends over several lines\näöüÄÖÜß", 'ä'], null, null], [["A text that\nextends over several lines\näöüÄÖÜß", 'ö'], null, null]]; | ||
probes_and_matchers = [[[`A text that\nextends over several lines\näöüÄÖÜß`, '\n'], null, null], [[`A text that\nextends over several lines\näöüÄÖÜß`, 'ä'], null, null], [[`A text that\nextends over several lines\näöüÄÖÜß`, 'ö'], null, null]]; | ||
for (i = 0, len = probes_and_matchers.length; i < len; i++) { | ||
@@ -154,0 +154,0 @@ [probe, matcher, error] = probes_and_matchers[i]; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,5 +0,5 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
//########################################################################################################### | ||
var $, $async, $drain, $show, $watch, CND, FS, OS, PATH, SP, alert, badge, debug, echo, help, info, log, rpr, test, urge, warn, whisper, | ||
var $, $async, $drain, $show, $watch, CND, FS, OS, PATH, SP, alert, badge, debug, defaults, echo, help, info, isa, jr, log, rpr, test, type_of, urge, validate, warn, whisper, | ||
modulo = function(a, b) { return (+a % (b = +b) + b) % b; }; | ||
@@ -40,3 +40,8 @@ | ||
({jr} = CND); | ||
//........................................................................................................... | ||
({isa, validate, defaults, type_of} = require('../types')); | ||
//........................................................................................................... | ||
SP = require('../..'); | ||
@@ -232,2 +237,263 @@ | ||
//----------------------------------------------------------------------------------------------------------- | ||
this["wye construction (sync)"] = async function(T, done) { | ||
var error, i, len, matcher, probe_A, probe_B, probes_and_matchers; | ||
probes_and_matchers = [[["abc", "UVWXYZ"], "abcUVWXYZ", null]]; | ||
for (i = 0, len = probes_and_matchers.length; i < len; i++) { | ||
[[probe_A, probe_B], matcher, error] = probes_and_matchers[i]; | ||
await T.perform([probe_A, probe_B], matcher, error, function() { | ||
return new Promise(function(resolve, reject) { | ||
var A_has_ended, B_has_ended, duct_A, duct_B, duct_C, end_source_C, last, pipeline_A, pipeline_B, pipeline_C, source_A, source_B, source_C; | ||
// wye = SP.new_wye() | ||
last = Symbol('last'); | ||
//..................................................................................................... | ||
source_A = probe_A; | ||
A_has_ended = false; | ||
B_has_ended = false; | ||
pipeline_A = []; | ||
pipeline_A.push(source_A); | ||
pipeline_A.push($watch(function(d) { | ||
return help('A', jr(d)); | ||
})); | ||
pipeline_A.push($({last}, function(d, send) { | ||
if (d === last) { | ||
A_has_ended = true; | ||
return end_source_C(); | ||
} | ||
return source_C.send(d); | ||
})); | ||
pipeline_A.push($drain(function() { | ||
return whisper('A'); | ||
})); | ||
//..................................................................................................... | ||
source_B = probe_B; | ||
pipeline_B = []; | ||
pipeline_B.push(source_B); | ||
pipeline_B.push($watch(function(d) { | ||
return urge('B', jr(d)); | ||
})); | ||
pipeline_B.push($({last}, function(d, send) { | ||
if (d === last) { | ||
B_has_ended = true; | ||
return end_source_C(); | ||
} | ||
return source_C.send(d); | ||
})); | ||
pipeline_B.push($drain(function() { | ||
return whisper('B'); | ||
})); | ||
//..................................................................................................... | ||
source_C = SP.new_push_source(); | ||
pipeline_C = []; | ||
pipeline_C.push(source_C); | ||
pipeline_C.push($watch(function(d) { | ||
return info('C', jr(d)); | ||
})); | ||
pipeline_C.push($drain(function(Σ) { | ||
whisper('C', jr(Σ)); | ||
return resolve(Σ.join('')); | ||
})); | ||
//..................................................................................................... | ||
end_source_C = function() { | ||
if (!(A_has_ended && B_has_ended)) { | ||
return; | ||
} | ||
return source_C.end(); | ||
}; | ||
//..................................................................................................... | ||
// pipeline_A.push wye | ||
duct_C = SP.pull(...pipeline_C); | ||
duct_A = SP.pull(...pipeline_A); | ||
duct_B = SP.pull(...pipeline_B); | ||
return null; | ||
}); | ||
}); | ||
} | ||
//......................................................................................................... | ||
done(); | ||
return null; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this["wye construction (async)"] = async function(T, done) { | ||
var error, i, len, matcher, probe_A, probe_B, probes_and_matchers; | ||
probes_and_matchers = [[["abc", "UVWXYZ"], "aUbVcWXYZ", null]]; | ||
for (i = 0, len = probes_and_matchers.length; i < len; i++) { | ||
[[probe_A, probe_B], matcher, error] = probes_and_matchers[i]; | ||
await T.perform([probe_A, probe_B], matcher, error, function() { | ||
return new Promise(function(resolve, reject) { | ||
var A_has_ended, B_has_ended, duct_A, duct_B, duct_C, end_source_C, last, pipeline_A, pipeline_B, pipeline_C, source_A, source_B, source_C; | ||
// wye = SP.new_wye() | ||
last = Symbol('last'); | ||
//..................................................................................................... | ||
source_A = probe_A; | ||
A_has_ended = false; | ||
B_has_ended = false; | ||
pipeline_A = []; | ||
pipeline_A.push(source_A); | ||
pipeline_A.push($watch(function(d) { | ||
return help('A', jr(d)); | ||
})); | ||
pipeline_A.push($async(function(d, send, done) { | ||
source_C.send(d); | ||
return done(); | ||
})); | ||
pipeline_A.push($({last}, function(d, send) { | ||
if (d !== last) { | ||
return; | ||
} | ||
A_has_ended = true; | ||
return end_source_C(); | ||
})); | ||
pipeline_A.push($drain(function() { | ||
return whisper('A'); | ||
})); | ||
//..................................................................................................... | ||
source_B = probe_B; | ||
pipeline_B = []; | ||
pipeline_B.push(source_B); | ||
pipeline_B.push($watch(function(d) { | ||
return urge('B', jr(d)); | ||
})); | ||
pipeline_B.push($async(function(d, send, done) { | ||
source_C.send(d); | ||
return done(); | ||
})); | ||
pipeline_B.push($({last}, function(d, send) { | ||
if (d !== last) { | ||
return; | ||
} | ||
B_has_ended = true; | ||
return end_source_C(); | ||
})); | ||
pipeline_B.push($drain(function() { | ||
return whisper('B'); | ||
})); | ||
//..................................................................................................... | ||
source_C = SP.new_push_source(); | ||
pipeline_C = []; | ||
pipeline_C.push(source_C); | ||
pipeline_C.push($watch(function(d) { | ||
return info('C', jr(d)); | ||
})); | ||
pipeline_C.push($drain(function(Σ) { | ||
whisper('C', jr(Σ)); | ||
return resolve(Σ.join('')); | ||
})); | ||
//..................................................................................................... | ||
end_source_C = function() { | ||
if (!(A_has_ended && B_has_ended)) { | ||
return; | ||
} | ||
return source_C.end(); | ||
}; | ||
//..................................................................................................... | ||
// pipeline_A.push wye | ||
duct_C = SP.pull(...pipeline_C); | ||
duct_A = SP.pull(...pipeline_A); | ||
duct_B = SP.pull(...pipeline_B); | ||
return null; | ||
}); | ||
}); | ||
} | ||
//......................................................................................................... | ||
done(); | ||
return null; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this["wye construction (source, transform, drain ducts)"] = async function(T, done) { | ||
await T.perform(null, null, null, function() { | ||
return new Promise(function(resolve, reject) { | ||
var pipeline; | ||
//....................................................................................................... | ||
pipeline = []; | ||
pipeline.push('abc'); | ||
pipeline.push($watch(function(d) { | ||
return help('A', jr(d)); | ||
})); | ||
pipeline.push(SP.new_wye('UVW')); | ||
pipeline.push($watch(function(d) { | ||
return urge('AB', jr(d)); | ||
})); | ||
SP.pull(...pipeline); | ||
return resolve(null); | ||
}); | ||
}); | ||
//......................................................................................................... | ||
await T.perform(null, null, null, function() { | ||
return new Promise(function(resolve, reject) { | ||
var pipeline; | ||
//....................................................................................................... | ||
pipeline = []; | ||
pipeline.push($watch(function(d) { | ||
return help('A', jr(d)); | ||
})); | ||
pipeline.push(SP.new_wye('UVW')); | ||
pipeline.push($watch(function(d) { | ||
return urge('AB', jr(d)); | ||
})); | ||
SP.pull(...pipeline); | ||
return resolve(null); | ||
}); | ||
}); | ||
//......................................................................................................... | ||
await T.perform(null, null, null, function() { | ||
return new Promise(function(resolve, reject) { | ||
var pipeline; | ||
//....................................................................................................... | ||
pipeline = []; | ||
pipeline.push($watch(function(d) { | ||
return help('A', jr(d)); | ||
})); | ||
pipeline.push(SP.new_wye('UVW')); | ||
pipeline.push($watch(function(d) { | ||
return urge('AB', jr(d)); | ||
})); | ||
pipeline.push($drain(function() {})); | ||
SP.pull(...pipeline); | ||
return resolve(null); | ||
}); | ||
}); | ||
//......................................................................................................... | ||
done(); | ||
return null; | ||
}; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this["wye construction (method)"] = async function(T, done) { | ||
var error, i, len, matcher, probe_A, probe_B, probes_and_matchers; | ||
probes_and_matchers = [[["abc", "UVWXYZ"], "abcUVWXYZ", null]]; | ||
for (i = 0, len = probes_and_matchers.length; i < len; i++) { | ||
[[probe_A, probe_B], matcher, error] = probes_and_matchers[i]; | ||
await T.perform([probe_A, probe_B], matcher, error, function() { | ||
return new Promise(function(resolve, reject) { | ||
var pipeline, source_A, source_B; | ||
// wye = SP.new_wye() | ||
//..................................................................................................... | ||
source_A = probe_A; | ||
source_B = probe_B; | ||
pipeline = []; | ||
pipeline.push(source_A); | ||
pipeline.push($watch(function(d) { | ||
return help('A', jr(d)); | ||
})); | ||
pipeline.push(SP.new_wye(source_B)); | ||
pipeline.push($watch(function(d) { | ||
return urge('AB', jr(d)); | ||
})); | ||
pipeline.push($drain(function(Σ) { | ||
whisper('AB', jr(Σ)); | ||
return resolve(Σ.join('')); | ||
})); | ||
SP.pull(...pipeline); | ||
return null; | ||
}); | ||
}); | ||
} | ||
//......................................................................................................... | ||
done(); | ||
return null; | ||
}; | ||
//########################################################################################################### | ||
@@ -241,3 +507,6 @@ if (module.parent == null) { | ||
// test @[ "leapfrogging compared to wye" ] | ||
// test @[ "wye 3" ] | ||
// test @[ "wye construction (sync)" ] | ||
// test @[ "wye construction (async)" ] | ||
// test @[ "wye construction (method)" ] | ||
// test @[ "wye construction (source, transform, drain ducts)" ] | ||
@@ -244,0 +513,0 @@ }).call(this); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ 'use strict'; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.4.1 | ||
// Generated by CoffeeScript 2.5.0 | ||
(function() { | ||
@@ -96,2 +96,25 @@ 'use strict'; | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.declare('steampipes_new_wye_settings', { | ||
tests: { | ||
"x is a object": function(x) { | ||
return this.isa.object(x); | ||
}, | ||
"x.mode is a text": function(x) { | ||
return this.isa.text(x.mode); | ||
}, | ||
"x.mode is known value": function(x) { | ||
var ref; | ||
return (ref = x.mode) === 'asis' || ref === 'interleave'; | ||
} | ||
} | ||
}); | ||
//----------------------------------------------------------------------------------------------------------- | ||
this.defaults = { | ||
steampipes_new_wye_settings: { | ||
mode: 'asis' | ||
} | ||
}; | ||
// #----------------------------------------------------------------------------------------------------------- | ||
@@ -103,3 +126,3 @@ // declare 'pipestreams_is_sink_or_through', | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// declare 'pipestreams_is_sink', | ||
@@ -110,3 +133,3 @@ // tests: | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// #----------------------------------------------------------------------------------------------------------- | ||
// declare 'pipestreams_is_source', | ||
@@ -113,0 +136,0 @@ // tests: |
{ | ||
"name": "steampipes", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "Fast, simple data pipelines", | ||
@@ -30,7 +30,8 @@ "main": "lib/main.js", | ||
"@uppy/fs-tail-stream": "^1.2.0", | ||
"atlas-html-stream": "^1.2.0", | ||
"cnd": "^4.9.0", | ||
"intertype": "^2.8.0", | ||
"datom": "^2.4.0", | ||
"intertype": "^3.1.0", | ||
"letsfreezethat": "^2.2.5", | ||
"multimix": "^2.1.1", | ||
"pipedreams": "^12.1.0" | ||
"multimix": "^2.1.1" | ||
}, | ||
@@ -37,0 +38,0 @@ "devDependencies": { |
@@ -12,2 +12,3 @@ | ||
- [How to Construct Sources, Transforms, and Sinks](#how-to-construct-sources-transforms-and-sinks) | ||
- [Sources](#sources) | ||
- [Transforms](#transforms) | ||
@@ -46,2 +47,32 @@ - [Sinks](#sinks) | ||
### Sources | ||
Valid SteamPipes sources include all JS values for which either | ||
``` | ||
CS │ JS | ||
──────────────────────────────┼───────────────────────────────────── | ||
for d from source │ for ( d of source ) { | ||
... │ ... } | ||
──────────────────────────────┴───────────────────────────────────── | ||
``` | ||
or | ||
``` | ||
CS │ JS | ||
──────────────────────────────┼───────────────────────────────────── | ||
for await d from source │ for await ( d of source ) { | ||
... │ ... } | ||
──────────────────────────────┴───────────────────────────────────── | ||
``` | ||
is valid. | ||
In addition, synchronous and asynchronous functions that, when called without arguments, return a value for | ||
which one of the iteration modes (sync or async) works correctly are allowed. Such a function will be called | ||
as late as possible, that is, not at pipline definition time, but only when a pipeline with a source and a | ||
drain has been constructed and is started with `pull()`. | ||
### Transforms | ||
@@ -249,4 +280,20 @@ | ||
### Future: JS Pipeline Operator | ||
see [Breaking Chains with Pipelines in Modern | ||
JavaScript](https://www.wix.engineering/post/breaking-chains-with-pipelines-in-modern-javascript) | ||
```js | ||
const result3 = numbers | ||
|> filter(#, v => v % 2 === 0) | ||
|> map(#, v => v + 1) | ||
|> slice(#, 0, 3) | ||
|> Array.from; | ||
``` | ||
* Lazy evaluation, no backpressure (?), built into the language. | ||
* Already usable with Babel. | ||
* Article discusses a number of alternatives with merits and demerits, must read. | ||
### To Do: Railway-Oriented Programming | ||
@@ -253,0 +300,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1070725
111
7773
349
7
19
+ Addedatlas-html-stream@^1.2.0
+ Addeddatom@^2.4.0
+ Addedatlas-html-stream@1.2.0(transitive)
+ Addedatlas-seq-matcher@1.0.2(transitive)
+ Addeddatom@2.5.0(transitive)
+ Addedemittery@0.5.1(transitive)
- Removedpipedreams@^12.1.0
- Removeddata-uri-to-buffer@2.0.2(transitive)
- Removedemittery@0.6.0(transitive)
- Removedget-source@1.0.42(transitive)
- Removedintertype@2.9.0(transitive)
- Removedlodash.flattendeep@4.4.0(transitive)
- Removedlooper@3.0.04.0.0(transitive)
- Removedpipedreams@12.1.1(transitive)
- Removedpipestreams@8.0.1(transitive)
- Removedpull-cont@0.1.1(transitive)
- Removedpull-many@1.0.9(transitive)
- Removedpull-map-last@1.0.0(transitive)
- Removedpull-merge@1.0.4(transitive)
- Removedpull-mux@0.1.3(transitive)
- Removedpull-pair@1.1.0(transitive)
- Removedpull-paramap@1.2.2(transitive)
- Removedpull-pause@0.0.2(transitive)
- Removedpull-pushable@2.2.0(transitive)
- Removedpull-split@0.2.1(transitive)
- Removedpull-stream@3.7.0(transitive)
- Removedpull-stream-to-stream@2.0.0(transitive)
- Removedpull-tee@2.0.1(transitive)
- Removedpull-through@1.0.18(transitive)
- Removedpull-utf8-decoder@1.0.2(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedstack-trace@0.0.10(transitive)
- Removedstream-to-pull-stream@1.7.3(transitive)
- Removedtimsort@0.3.0(transitive)
Updatedintertype@^3.1.0