Comparing version 2.8.0 to 2.9.0
@@ -278,3 +278,3 @@ const { EventEmitter } = require('events') | ||
while ((tail === this.queue.shift()) !== undefined) { | ||
while ((tail = this.queue.shift()) !== undefined) { | ||
pending.push(tail) | ||
@@ -634,2 +634,3 @@ } | ||
this._readableState.updateNextTick() | ||
return this | ||
} | ||
@@ -639,2 +640,3 @@ | ||
this._duplexState &= READ_PAUSED | ||
return this | ||
} | ||
@@ -684,2 +686,6 @@ | ||
static isPaused (rs) { | ||
return (rs._duplexState & READ_RESUMED) === 0 | ||
} | ||
[asyncIterator] () { | ||
@@ -686,0 +692,0 @@ const stream = this |
{ | ||
"name": "streamx", | ||
"version": "2.8.0", | ||
"version": "2.9.0", | ||
"description": "An iteration of the Node.js core streams with a series of improvements", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,3 +25,3 @@ # streamx | ||
Close is *always* the last event emitted and `destroy` is always ran. | ||
Close is *always* the last event emitted and `destroy` is always run. | ||
@@ -197,2 +197,4 @@ #### `pipe()` error handles | ||
Returns this stream instance. | ||
#### `rs.resume()` | ||
@@ -207,2 +209,8 @@ | ||
Returns this stream instance. | ||
#### `bool = Readable.isPaused(rs)` | ||
Returns `true` if the stream is paused, else `false`. | ||
#### `writableStream = rs.pipe(writableStream, [callback])` | ||
@@ -209,0 +217,0 @@ |
@@ -24,2 +24,26 @@ const tape = require('tape') | ||
function nextImmediate () { | ||
return new Promise(resolve => setImmediate(resolve)) | ||
} | ||
tape('pause', async function (t) { | ||
const r = new Readable() | ||
const buffered = [] | ||
t.equals(Readable.isPaused(r), true, 'starting off paused') | ||
r.on('data', data => buffered.push(data)) | ||
r.on('close', () => t.end()) | ||
r.push('hello') | ||
await nextImmediate() | ||
t.equals(r.pause(), r, '.pause() returns self') | ||
t.equals(Readable.isPaused(r), true, '.pause() marks stream as paused') | ||
r.push('world') | ||
await nextImmediate() | ||
t.same(buffered, ['hello'], '.pause() prevents data to be read') | ||
t.equals(r.resume(), r, '.resume() returns self') | ||
t.equals(Readable.isPaused(r), false, '.resume() marks stream as resumed') | ||
await nextImmediate() | ||
t.same(buffered, ['hello', 'world']) | ||
r.push(null) | ||
}) | ||
tape('resume', function (t) { | ||
@@ -137,1 +161,15 @@ const r = new Readable() | ||
}) | ||
tape('unshift', async function (t) { | ||
const r = new Readable() | ||
r.push(1) | ||
r.push(2) | ||
r.unshift(0) | ||
r.push(null) | ||
const inc = [] | ||
for await (const entry of r) { | ||
inc.push(entry) | ||
} | ||
t.same(inc, [0, 1, 2]) | ||
t.end() | ||
}) |
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
60747
1602
412