Node updated. Some todos.
This commit is contained in:
10
Scripts/node_modules/streamx/README.md
generated
vendored
10
Scripts/node_modules/streamx/README.md
generated
vendored
@ -459,6 +459,16 @@ Same as normal pipeline except instead of returning the last stream it returns
|
||||
a promise representing the done callback. Note you should error handle this
|
||||
promise if you use this version.
|
||||
|
||||
## Helpers
|
||||
|
||||
#### `bool = isStream(stream)`
|
||||
|
||||
#### `bool = isStreamx(stream)`
|
||||
|
||||
#### `err = getStreamError(stream, [options])`
|
||||
|
||||
Returns `null` if the stream has no errors.
|
||||
|
||||
## Utilities
|
||||
|
||||
Streamx aims to be minimal and stable. It therefore only contains a minimal set of utilities.
|
||||
|
||||
91
Scripts/node_modules/streamx/index.js
generated
vendored
91
Scripts/node_modules/streamx/index.js
generated
vendored
@ -4,11 +4,12 @@ const PREMATURE_CLOSE = new Error('Premature close')
|
||||
|
||||
const queueTick = require('queue-tick')
|
||||
const FIFO = require('fast-fifo')
|
||||
const TextDecoder = require('text-decoder')
|
||||
|
||||
/* eslint-disable no-multi-spaces */
|
||||
|
||||
// 28 bits used total (4 from shared, 14 from read, and 10 from write)
|
||||
const MAX = ((1 << 28) - 1)
|
||||
// 29 bits used total (4 from shared, 14 from read, and 11 from write)
|
||||
const MAX = ((1 << 29) - 1)
|
||||
|
||||
// Shared state
|
||||
const OPENING = 0b0001
|
||||
@ -55,17 +56,18 @@ const READ_NOT_UPDATING = MAX ^ READ_UPDATING
|
||||
const READ_NO_READ_AHEAD = MAX ^ READ_READ_AHEAD
|
||||
const READ_PAUSED_NO_READ_AHEAD = MAX ^ READ_RESUMED_READ_AHEAD
|
||||
|
||||
// Write state (18 bit offset, 4 bit offset from shared state and 13 from read state)
|
||||
const WRITE_ACTIVE = 0b0000000001 << 18
|
||||
const WRITE_UPDATING = 0b0000000010 << 18
|
||||
const WRITE_PRIMARY = 0b0000000100 << 18
|
||||
const WRITE_QUEUED = 0b0000001000 << 18
|
||||
const WRITE_UNDRAINED = 0b0000010000 << 18
|
||||
const WRITE_DONE = 0b0000100000 << 18
|
||||
const WRITE_EMIT_DRAIN = 0b0001000000 << 18
|
||||
const WRITE_NEXT_TICK = 0b0010000000 << 18
|
||||
const WRITE_WRITING = 0b0100000000 << 18
|
||||
const WRITE_FINISHING = 0b1000000000 << 18
|
||||
// Write state (18 bit offset, 4 bit offset from shared state and 14 from read state)
|
||||
const WRITE_ACTIVE = 0b00000000001 << 18
|
||||
const WRITE_UPDATING = 0b00000000010 << 18
|
||||
const WRITE_PRIMARY = 0b00000000100 << 18
|
||||
const WRITE_QUEUED = 0b00000001000 << 18
|
||||
const WRITE_UNDRAINED = 0b00000010000 << 18
|
||||
const WRITE_DONE = 0b00000100000 << 18
|
||||
const WRITE_EMIT_DRAIN = 0b00001000000 << 18
|
||||
const WRITE_NEXT_TICK = 0b00010000000 << 18
|
||||
const WRITE_WRITING = 0b00100000000 << 18
|
||||
const WRITE_FINISHING = 0b01000000000 << 18
|
||||
const WRITE_CORKED = 0b10000000000 << 18
|
||||
|
||||
const WRITE_NOT_ACTIVE = MAX ^ (WRITE_ACTIVE | WRITE_WRITING)
|
||||
const WRITE_NON_PRIMARY = MAX ^ WRITE_PRIMARY
|
||||
@ -74,6 +76,7 @@ const WRITE_DRAINED = MAX ^ WRITE_UNDRAINED
|
||||
const WRITE_NOT_QUEUED = MAX ^ WRITE_QUEUED
|
||||
const WRITE_NOT_NEXT_TICK = MAX ^ WRITE_NEXT_TICK
|
||||
const WRITE_NOT_UPDATING = MAX ^ WRITE_UPDATING
|
||||
const WRITE_NOT_CORKED = MAX ^ WRITE_CORKED
|
||||
|
||||
// Combined shared state
|
||||
const ACTIVE = READ_ACTIVE | WRITE_ACTIVE
|
||||
@ -101,7 +104,7 @@ const WRITE_PRIMARY_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_DONE
|
||||
const WRITE_QUEUED_AND_UNDRAINED = WRITE_QUEUED | WRITE_UNDRAINED
|
||||
const WRITE_QUEUED_AND_ACTIVE = WRITE_QUEUED | WRITE_ACTIVE
|
||||
const WRITE_DRAIN_STATUS = WRITE_QUEUED | WRITE_UNDRAINED | OPEN_STATUS | WRITE_ACTIVE
|
||||
const WRITE_STATUS = OPEN_STATUS | WRITE_ACTIVE | WRITE_QUEUED
|
||||
const WRITE_STATUS = OPEN_STATUS | WRITE_ACTIVE | WRITE_QUEUED | WRITE_CORKED
|
||||
const WRITE_PRIMARY_AND_ACTIVE = WRITE_PRIMARY | WRITE_ACTIVE
|
||||
const WRITE_ACTIVE_AND_WRITING = WRITE_ACTIVE | WRITE_WRITING
|
||||
const WRITE_FINISHING_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_QUEUED_AND_ACTIVE | WRITE_DONE
|
||||
@ -287,7 +290,14 @@ class ReadableState {
|
||||
return false
|
||||
}
|
||||
|
||||
if (this.map !== null) data = this.map(data)
|
||||
if (this.map !== null) {
|
||||
data = this.map(data)
|
||||
if (data === null) {
|
||||
stream._duplexState &= READ_PUSHED
|
||||
return this.buffered < this.highWaterMark
|
||||
}
|
||||
}
|
||||
|
||||
this.buffered += this.byteLength(data)
|
||||
this.queue.push(data)
|
||||
|
||||
@ -684,6 +694,19 @@ class Readable extends Stream {
|
||||
if (this._readableState.readAhead === false) this._duplexState &= READ_NO_READ_AHEAD
|
||||
if (opts.read) this._read = opts.read
|
||||
if (opts.eagerOpen) this._readableState.updateNextTick()
|
||||
if (opts.encoding) this.setEncoding(opts.encoding)
|
||||
}
|
||||
}
|
||||
|
||||
setEncoding (encoding) {
|
||||
const dec = new TextDecoder(encoding)
|
||||
const map = this._readableState.map || echo
|
||||
this._readableState.map = mapOrSkip
|
||||
return this
|
||||
|
||||
function mapOrSkip (data) {
|
||||
const next = dec.push(data)
|
||||
return next === '' && (data.byteLength !== 0 || dec.remaining > 0) ? null : map(next)
|
||||
}
|
||||
}
|
||||
|
||||
@ -847,6 +870,15 @@ class Writable extends Stream {
|
||||
}
|
||||
}
|
||||
|
||||
cork () {
|
||||
this._duplexState |= WRITE_CORKED
|
||||
}
|
||||
|
||||
uncork () {
|
||||
this._duplexState &= WRITE_NOT_CORKED
|
||||
this._writableState.updateNextTick()
|
||||
}
|
||||
|
||||
_writev (batch, cb) {
|
||||
cb(null)
|
||||
}
|
||||
@ -901,6 +933,15 @@ class Duplex extends Readable { // and Writable
|
||||
}
|
||||
}
|
||||
|
||||
cork () {
|
||||
this._duplexState |= WRITE_CORKED
|
||||
}
|
||||
|
||||
uncork () {
|
||||
this._duplexState &= WRITE_NOT_CORKED
|
||||
this._writableState.updateNextTick()
|
||||
}
|
||||
|
||||
_writev (batch, cb) {
|
||||
cb(null)
|
||||
}
|
||||
@ -1060,6 +1101,10 @@ function pipeline (stream, ...streams) {
|
||||
}
|
||||
}
|
||||
|
||||
function echo (s) {
|
||||
return s
|
||||
}
|
||||
|
||||
function isStream (stream) {
|
||||
return !!stream._readableState || !!stream._writableState
|
||||
}
|
||||
@ -1068,9 +1113,19 @@ function isStreamx (stream) {
|
||||
return typeof stream._duplexState === 'number' && isStream(stream)
|
||||
}
|
||||
|
||||
function getStreamError (stream) {
|
||||
function isEnded (stream) {
|
||||
return !!stream._readableState && stream._readableState.ended
|
||||
}
|
||||
|
||||
function isFinished (stream) {
|
||||
return !!stream._writableState && stream._writableState.ended
|
||||
}
|
||||
|
||||
function getStreamError (stream, opts = {}) {
|
||||
const err = (stream._readableState && stream._readableState.error) || (stream._writableState && stream._writableState.error)
|
||||
return err === STREAM_DESTROYED ? null : err // only explicit errors
|
||||
|
||||
// avoid implicit errors by default
|
||||
return (!opts.all && err === STREAM_DESTROYED) ? null : err
|
||||
}
|
||||
|
||||
function isReadStreamx (stream) {
|
||||
@ -1100,6 +1155,8 @@ module.exports = {
|
||||
pipelinePromise,
|
||||
isStream,
|
||||
isStreamx,
|
||||
isEnded,
|
||||
isFinished,
|
||||
getStreamError,
|
||||
Stream,
|
||||
Writable,
|
||||
|
||||
8
Scripts/node_modules/streamx/package.json
generated
vendored
8
Scripts/node_modules/streamx/package.json
generated
vendored
@ -1,13 +1,15 @@
|
||||
{
|
||||
"name": "streamx",
|
||||
"version": "2.16.1",
|
||||
"version": "2.20.1",
|
||||
"description": "An iteration of the Node.js core streams with a series of improvements",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"fast-fifo": "^1.1.0",
|
||||
"queue-tick": "^1.0.1"
|
||||
"fast-fifo": "^1.3.2",
|
||||
"queue-tick": "^1.0.1",
|
||||
"text-decoder": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"b4a": "^1.6.6",
|
||||
"brittle": "^3.1.1",
|
||||
"end-of-stream": "^1.4.4",
|
||||
"standard": "^17.0.0"
|
||||
|
||||
Reference in New Issue
Block a user