Comparing version 1.1.10 to 1.1.11
10
index.js
@@ -56,3 +56,3 @@ 'use strict' | ||
return this.flowing | ||
? (this.emit('data', chunk), true) | ||
? (this.emit('data', chunk), this.flowing) | ||
: (this.buffer.push(chunk), false) | ||
@@ -91,3 +91,3 @@ } finally { | ||
this.emit('data', chunk) | ||
if (!this.buffer.length) | ||
if (!this.buffer.length && !this[EOF]) | ||
this.emit('drain') | ||
@@ -116,4 +116,6 @@ return chunk | ||
this[FLUSH]() | ||
else if (this[EOF]) | ||
this[MAYBE_EMIT_END]() | ||
else | ||
this[MAYBE_EMIT_END]() | ||
this.emit('drain') | ||
} | ||
@@ -136,3 +138,3 @@ | ||
if (!this.buffer.length) | ||
if (!this.buffer.length && !this[EOF]) | ||
this.emit('drain') | ||
@@ -139,0 +141,0 @@ } |
{ | ||
"name": "minipass", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"description": "minimal implementation of a PassThrough stream", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
const MiniPass = require('../') | ||
const t = require('tap') | ||
const EE = require('events').EventEmitter | ||
@@ -25,3 +26,3 @@ t.test('some basic piping and writing', async t => { | ||
dest.pause() | ||
t.equal(mp.write('after pause'), true, 'true when dest is paused') | ||
t.equal(mp.write('after pause'), false, 'false when dest is paused') | ||
t.equal(mp.write('after false'), false, 'false when not flowing') | ||
@@ -229,1 +230,29 @@ t.equal(dest.buffer.length, 1, '1 item is buffered in dest') | ||
}) | ||
t.test('emit drain on resume, even if no flush', t => { | ||
const mp = new MiniPass() | ||
mp.encoding = 'utf8' | ||
const chunks = [] | ||
class SlowStream extends EE { | ||
write (chunk) { | ||
chunks.push(chunk) | ||
setTimeout(_ => this.emit('drain')) | ||
return false | ||
} | ||
end () { return this.write() } | ||
} | ||
const ss = new SlowStream() | ||
mp.pipe(ss) | ||
t.ok(mp.flowing, 'flowing, because piped') | ||
t.equal(mp.write('foo'), false, 'write() returns false, backpressure') | ||
t.equal(mp.buffer.length, 0, 'buffer len is 0') | ||
t.equal(mp.flowing, false, 'flowing false, awaiting drain') | ||
t.same(chunks, ['foo'], 'chunk made it through') | ||
mp.once('drain', _ => { | ||
t.pass('received mp drain event') | ||
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
15821
9
491