Comparing version 2.0.1 to 2.1.0
16
index.js
@@ -81,2 +81,3 @@ const { EventEmitter } = require('events') | ||
const SHOULD_NOT_READ = OPEN_STATUS | READ_ACTIVE | READ_ENDING | READ_DONE | READ_NEEDS_PUSH | ||
const READ_BACKPRESSURE_STATUS = DESTROY_STATUS | READ_ENDING | READ_DONE | ||
@@ -91,2 +92,3 @@ // Combined write state | ||
const WRITE_FINISHING_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_QUEUED | ||
const WRITE_BACKPRESSURE_STATUS = WRITE_UNDRAINED | DESTROY_STATUS | WRITE_FINISHING | WRITE_DONE | ||
@@ -486,2 +488,3 @@ const asyncIterator = Symbol.asyncIterator || Symbol('asyncIterator') | ||
if (opts.destroy) this._destroy = opts.destroy | ||
if (opts.predestroy) this._predestroy = opts.predestroy | ||
} | ||
@@ -498,2 +501,6 @@ } | ||
_predestroy () { | ||
// does nothing | ||
} | ||
get destroyed () { | ||
@@ -511,2 +518,3 @@ return (this._duplexState & DESTROYED) !== 0 | ||
this._duplexState = (this._duplexState | DESTROYING) & NON_PRIMARY | ||
this._predestroy() | ||
if (this._readableState !== null) { | ||
@@ -592,2 +600,6 @@ this._readableState.error = err | ||
static isBackpressured (rs) { | ||
return (rs._duplexState & READ_BACKPRESSURE_STATUS) !== 0 || rs._readableState.buffered >= rs._readableState.highWaterMark | ||
} | ||
[asyncIterator] () { | ||
@@ -648,2 +660,6 @@ const stream = this | ||
static isBackpressured (ws) { | ||
return (ws._duplexState & WRITE_BACKPRESSURE_STATUS) !== 0 | ||
} | ||
write (data) { | ||
@@ -650,0 +666,0 @@ this._writableState.updateNextTick() |
{ | ||
"name": "streamx", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "An iteration of the Node.js core streams with a series of improvements", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -148,2 +148,10 @@ # streamx | ||
#### `rs._predestroy()` | ||
A simple hook that is called as soon as the first `stream.destroy()` call is invoked. | ||
Use this in case you need to cancel pending reads (if possible) instead of waiting for them to finish. | ||
Can also be set using `options.predestroy` in the constructor. | ||
#### `rs.destroy([error])` | ||
@@ -202,2 +210,6 @@ | ||
#### `bool = Readable.isBackpressured(rs)` | ||
Static method to check if a readable stream is currently under backpressure. | ||
## Writable Stream | ||
@@ -245,2 +257,10 @@ | ||
#### `ws._predestroy()` | ||
A simple hook that is called as soon as the first `stream.destroy()` call is invoked. | ||
Use this in case you need to cancel pending writes (if possible) instead of waiting for them to finish. | ||
Can also be set using `options.predestroy` in the constructor. | ||
#### `ws.destroy([error])` | ||
@@ -296,2 +316,6 @@ | ||
#### `bool = Writable.isBackpressured(ws)` | ||
Static method to check if a writable stream is currently under backpressure. | ||
## Duplex Stream | ||
@@ -298,0 +322,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
42995
11
987
356