simple promise-based streams.
var q = ;var qs = ;var r = ;r;r;r;r;r;// 10// 20// 30// 23
$ npm install q-stream
Creates a new q-stream based transform stream.
opts is given, it is passed through to the base
Transform constructor as the options to use to create the stream. In contrast to the base
Transform constructor and through2, q-stream sets
true by default (since this mode is used so often).
fn is given, is is used as the transform stream's
fn should take the form
function(chunk, enc), where
chunk is the current chunk to be transformed and
enc is the encoding type if
chunk is a
string. In contrast to the original
_transform function, no callback should be provided. Instead, the return value is used as the result of the chunk's transformation.
fn may also return a promise fulfulled with the chunk's transformation result. Similar to the original
_transform function, the transformation result is optional, so a return value does not need to be given.
Sets the function to be invoked as part of the stream's flush. By default, this function is a 'no op'.
fn is not provided with any arguments, and may optionally provide a return value to be used to be used to resolve the stream's promise. Returns the stream to allow for further chaining.
Returns a promise that will be fulfilled at the end of the stream's flush with the return value of the stream's flush function result. Note that the promise will be fulfilled just before the stream's
'end' event is emitted.
If an error occured inside the stream or inside the stream's flush function, the promise will be rejected with the error that occured.
Note that if
.promise() is never invoked, errors occuring in the stream will be rethrown. However, if
.promise() is invoked, the errors will no longer be rethrown, and it is the programmer's responsibility the returned promise properly. See q's
promise.done for how to handle the returned promise.
Returns a new transform stream that accepts reads in data from a readable stream and sends out the data concatenated into a single output value.
var s = ;s;s;s;s;// [ 1, 2, 3 ]
qs.concat() is a thin wrapper around concat-stream, but works a little differently.
concat-stream is a writeable stream that would usually be found at the end of a readable stream's chain of
.pipe()s, with the given callback function allowing the concatenated result to be retrieved. Further piping isn't possible, since it is a writeable-only stream.
qs.concat() also expects to be used as part of a readable stream's chain of
pipe()s, but its output can be piped into other streams (as shown in the example above).
qs.concat()'s promise is also fulfilled with the concatenation result for cases where further piping isn't necessary:
var s = ;s;s;s;s;// [ 1, 2, 3 ]
opts is given, it is passed through to both the newly created stream, and to its internal concat-stream.
Returns a new transform stream that accepts only a single value to be written before ending. The stream's promise is also fulfilled with the same single value.
var t = qs;t;t;// I am done now
opts is given, it is passed through to the newly created stream.
Returns a oneshot stream with the given value
v already written to it. If
v is a stream, it instead simply returned.
v is a stream or not. If
'pipe' as a function property, it assumed to be a stream.
console; // falseconsole; // true