scramjet-core
Advanced tools
Comparing version 4.31.4 to 4.31.6
@@ -704,19 +704,16 @@ const {PromiseTransformStream} = require("./util/promise-transform-stream"); | ||
let condition = true; | ||
const out = this._selfInstance({ | ||
promiseTransform: func, | ||
beforeTransform: (chunk) => condition ? chunk : Promise.reject(DataStream.filter), | ||
afterTransform: (chunk, ret) => { | ||
if (!ret) { | ||
condition = false; | ||
const out = this._selfInstance(); | ||
return this.tap().pipe(out.filter( | ||
(chunk) => { | ||
const result = condition && func(chunk); | ||
if (condition != result) { | ||
condition = result; | ||
this.unpipe(out); | ||
out.end(); | ||
return Promise.reject(DataStream.filter); | ||
} else { | ||
return condition ? chunk : Promise.reject(DataStream.filter); | ||
} | ||
}, | ||
referrer: this | ||
}); | ||
return this.pipe(out); | ||
return Promise | ||
.resolve(result) | ||
.then(result => result ? chunk : Promise.reject(DataStream.filter)); | ||
} | ||
)); | ||
} | ||
@@ -735,3 +732,17 @@ | ||
until(func) { | ||
return this.while((...args) => Promise.resolve(func(...args)).then((a) => !a)); | ||
let condition = false; | ||
const out = this._selfInstance(); | ||
return this.tap().pipe(out.filter( | ||
(chunk) => { | ||
const result = condition || func(chunk); | ||
if (condition != result) { | ||
condition = result; | ||
this.unpipe(out); | ||
} | ||
return Promise | ||
.resolve(result) | ||
.then(result => !result ? chunk : Promise.reject(DataStream.filter)); | ||
} | ||
)); | ||
} | ||
@@ -960,4 +971,11 @@ | ||
* @property {DataStream} [referrer=null] a referring stream to point to (if possible the transforms will be pushed to it | ||
* @property {boolean} [objectMode=true] should the object mode be used | ||
* instead of creating a new stream) | ||
* @property {boolean} [objectMode=true] should the object mode be used instead of creating a new stream) | ||
* @property {number} [highWaterMark] The maximum number of bytes to store in the internal buffer before ceasing to read from the underlying resource. Default: 16384 (16KB), or 16 for objectMode streams. | ||
* @property {string} [encoding] If specified, then buffers will be decoded to strings using the specified encoding. Default: null. | ||
* @property {boolean} [objectMode] Whether this stream should behave as a stream of objects. Meaning that stream.read(n) returns a single value instead of a Buffer of size n. Default: false. | ||
* @property {boolean} [emitClose] Whether or not the stream should emit 'close' after it has been destroyed. Default: true. | ||
* @property {Function} [read] Implementation for the stream._read() method. | ||
* @property {Function} [destroy] Implementation for the stream._destroy() method. | ||
* @property {Function} [construct] Implementation for the stream._construct() method. | ||
* @property {boolean} [autoDestroy] Whether this stream should automatically call .destroy() on itself after ending. Default: true. | ||
*/ | ||
@@ -964,0 +982,0 @@ |
{ | ||
"name": "scramjet-core", | ||
"version": "4.31.4", | ||
"version": "4.31.6", | ||
"description": "A pluggable minimal version of Scramjet that focuses only on stream transform and exposes only core features", | ||
@@ -69,5 +69,5 @@ "main": "lib/index.js", | ||
"nodeunit-tape-compat": "^1.3.66", | ||
"scramjet": "^4.35.5", | ||
"scramjet": "^4.35.6", | ||
"tape": "^5.0.1" | ||
} | ||
} |
239026
4759