writable-consumable-stream
Advanced tools
Comparing version 3.0.1 to 4.0.0
@@ -39,6 +39,10 @@ class Consumer { | ||
clearActiveTimeout() { | ||
clearTimeout(this._timeoutId); | ||
delete this._timeoutId; | ||
} | ||
write(packet) { | ||
if (this._timeoutId !== undefined) { | ||
clearTimeout(this._timeoutId); | ||
delete this._timeoutId; | ||
this.clearActiveTimeout(packet); | ||
} | ||
@@ -53,7 +57,6 @@ this.applyBackpressure(packet); | ||
kill(value) { | ||
this._killPacket = {value, done: true}; | ||
if (this._timeoutId !== undefined) { | ||
clearTimeout(this._timeoutId); | ||
delete this._timeoutId; | ||
this.clearActiveTimeout(this._killPacket); | ||
} | ||
this._killPacket = {value, done: true}; | ||
this._destroy(); | ||
@@ -60,0 +63,0 @@ |
{ | ||
"name": "writable-consumable-stream", | ||
"version": "3.0.1", | ||
"version": "4.0.0", | ||
"description": "An async stream which can be iterated over using a for-await-of loop.", | ||
@@ -30,4 +30,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"consumable-stream": "^2.0.0" | ||
"consumable-stream": "^3.0.0" | ||
} | ||
} |
@@ -461,3 +461,3 @@ const WritableConsumableStream = require('../index'); | ||
it('should cancel timeout when stream is killed', async () => { | ||
it('should throw a timeout error early when stream is killed', async () => { | ||
(async () => { | ||
@@ -471,7 +471,14 @@ await wait(10); | ||
await Promise.race([ | ||
stream.once(50), // This should not throw an error. | ||
wait(100) // This one should execute first. | ||
]); | ||
let error; | ||
try { | ||
await Promise.race([ | ||
stream.once(200), // This should throw an error early. | ||
wait(100) | ||
]); | ||
} catch (err) { | ||
error = err; | ||
} | ||
assert.equal(error.name, 'TimeoutError'); | ||
let backpressure = stream.getBackpressure(); | ||
@@ -478,0 +485,0 @@ assert.equal(backpressure, 0); |
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
58330
1560
+ Addedconsumable-stream@3.0.0(transitive)
- Removedconsumable-stream@2.0.0(transitive)
Updatedconsumable-stream@^3.0.0