Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

streamx

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streamx - npm Package Compare versions

Comparing version 2.14.3 to 2.15.0

162

index.js

@@ -10,3 +10,3 @@ const { EventEmitter } = require('events')

// 26 bits used total (4 from shared, 13 from read, and 10 from write)
// 27 bits used total (4 from shared, 13 from read, and 10 from write)
const MAX = ((1 << 27) - 1)

@@ -25,4 +25,4 @@

const READ_ACTIVE = 0b0000000000001 << 4
const READ_PRIMARY = 0b0000000000010 << 4
const READ_SYNC = 0b0000000000100 << 4
const READ_UPDATING = 0b0000000000010 << 4
const READ_PRIMARY = 0b0000000000100 << 4
const READ_QUEUED = 0b0000000001000 << 4

@@ -36,3 +36,3 @@ const READ_RESUMED = 0b0000000010000 << 4

const READ_DONE = 0b0010000000000 << 4
const READ_NEXT_TICK = 0b0100000000001 << 4 // also active
const READ_NEXT_TICK = 0b0100000000000 << 4
const READ_NEEDS_PUSH = 0b1000000000000 << 4

@@ -42,4 +42,3 @@

const READ_FLOWING = READ_RESUMED | READ_PIPE_DRAINED
const READ_ACTIVE_AND_SYNC = READ_ACTIVE | READ_SYNC
const READ_ACTIVE_AND_SYNC_AND_NEEDS_PUSH = READ_ACTIVE | READ_SYNC | READ_NEEDS_PUSH
const READ_ACTIVE_AND_NEEDS_PUSH = READ_ACTIVE | READ_NEEDS_PUSH
const READ_PRIMARY_AND_ACTIVE = READ_PRIMARY | READ_ACTIVE

@@ -51,3 +50,2 @@ const READ_EMIT_READABLE_AND_QUEUED = READ_EMIT_READABLE | READ_QUEUED

const READ_NON_PRIMARY_AND_PUSHED = MAX ^ (READ_PRIMARY | READ_NEEDS_PUSH)
const READ_NOT_SYNC = MAX ^ READ_SYNC
const READ_PUSHED = MAX ^ READ_NEEDS_PUSH

@@ -59,7 +57,8 @@ const READ_PAUSED = MAX ^ READ_RESUMED

const READ_NOT_NEXT_TICK = MAX ^ READ_NEXT_TICK
const READ_NOT_UPDATING = MAX ^ READ_UPDATING
// Write state (17 bit offset, 4 bit offset from shared state and 13 from read state)
const WRITE_ACTIVE = 0b0000000001 << 17
const WRITE_PRIMARY = 0b0000000010 << 17
const WRITE_SYNC = 0b0000000100 << 17
const WRITE_UPDATING = 0b0000000010 << 17
const WRITE_PRIMARY = 0b0000000100 << 17
const WRITE_QUEUED = 0b0000001000 << 17

@@ -69,8 +68,7 @@ const WRITE_UNDRAINED = 0b0000010000 << 17

const WRITE_EMIT_DRAIN = 0b0001000000 << 17
const WRITE_NEXT_TICK = 0b0010000001 << 17 // also active
const WRITE_FINISHING = 0b0100000000 << 17
const WRITE_WRITING = 0b1000000000 << 17
const WRITE_NEXT_TICK = 0b0010000000 << 17
const WRITE_WRITING = 0b0100000000 << 17
const WRITE_FINISHING = 0b1000000000 << 17
const WRITE_NOT_ACTIVE = MAX ^ (WRITE_ACTIVE | WRITE_WRITING)
const WRITE_NOT_SYNC = MAX ^ WRITE_SYNC
const WRITE_NON_PRIMARY = MAX ^ WRITE_PRIMARY

@@ -81,2 +79,3 @@ const WRITE_NOT_FINISHING = MAX ^ WRITE_FINISHING

const WRITE_NOT_NEXT_TICK = MAX ^ WRITE_NEXT_TICK
const WRITE_NOT_UPDATING = MAX ^ WRITE_UPDATING

@@ -102,2 +101,3 @@ // Combined shared state

const READ_BACKPRESSURE_STATUS = DESTROY_STATUS | READ_ENDING | READ_DONE
const READ_UPDATE_SYNC_STATUS = READ_UPDATING | OPEN_STATUS | READ_NEXT_TICK | READ_PRIMARY

@@ -111,5 +111,6 @@ // Combined write state

const WRITE_PRIMARY_AND_ACTIVE = WRITE_PRIMARY | WRITE_ACTIVE
const WRITE_ACTIVE_AND_SYNC = WRITE_ACTIVE | WRITE_SYNC | WRITE_WRITING
const WRITE_ACTIVE_AND_WRITING = WRITE_ACTIVE | WRITE_WRITING
const WRITE_FINISHING_STATUS = OPEN_STATUS | WRITE_FINISHING | WRITE_QUEUED_AND_ACTIVE | WRITE_DONE
const WRITE_BACKPRESSURE_STATUS = WRITE_UNDRAINED | DESTROY_STATUS | WRITE_FINISHING | WRITE_DONE
const WRITE_UPDATE_SYNC_STATUS = WRITE_UPDATING | OPEN_STATUS | WRITE_NEXT_TICK | WRITE_PRIMARY

@@ -154,6 +155,5 @@ const asyncIterator = Symbol.asyncIterator || Symbol('asyncIterator')

const data = this.queue.shift()
const stream = this.stream
this.buffered -= this.byteLength(data)
if (this.buffered === 0) stream._duplexState &= WRITE_NOT_QUEUED
if (this.buffered === 0) this.stream._duplexState &= WRITE_NOT_QUEUED

@@ -185,10 +185,15 @@ return data

while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED) {
const data = this.shift()
stream._duplexState |= WRITE_ACTIVE_AND_SYNC
stream._write(data, this.afterWrite)
stream._duplexState &= WRITE_NOT_SYNC
}
stream._duplexState |= WRITE_UPDATING
if ((stream._duplexState & WRITE_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary()
do {
while ((stream._duplexState & WRITE_STATUS) === WRITE_QUEUED) {
const data = this.shift()
stream._duplexState |= WRITE_ACTIVE_AND_WRITING
stream._write(data, this.afterWrite)
}
if ((stream._duplexState & WRITE_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary()
} while (this.continueUpdate() === true)
stream._duplexState &= WRITE_NOT_UPDATING
}

@@ -219,6 +224,17 @@

continueUpdate () {
if ((this.stream._duplexState & WRITE_NEXT_TICK) === 0) return false
this.stream._duplexState &= WRITE_NOT_NEXT_TICK
return true
}
updateCallback () {
if ((this.stream._duplexState & WRITE_UPDATE_SYNC_STATUS) === WRITE_PRIMARY) this.update()
else this.updateNextTick()
}
updateNextTick () {
if ((this.stream._duplexState & WRITE_NEXT_TICK) !== 0) return
this.stream._duplexState |= WRITE_NEXT_TICK
queueTick(this.afterUpdateNextTick)
if ((this.stream._duplexState & WRITE_UPDATING) === 0) queueTick(this.afterUpdateNextTick)
}

@@ -300,14 +316,12 @@ }

unshift (data) {
let tail
const pending = []
const pending = [this.map !== null ? this.map(data) : data]
while (this.buffered > 0) pending.push(this.shift())
while ((tail = this.queue.shift()) !== undefined) {
pending.push(tail)
for (let i = 0; i < pending.length - 1; i++) {
const data = pending[i]
this.buffered += this.byteLength(data)
this.queue.push(data)
}
this.push(data)
for (let i = 0; i < pending.length; i++) {
this.queue.push(pending[i])
}
this.push(pending[pending.length - 1])
}

@@ -341,17 +355,22 @@

this.drain()
stream._duplexState |= READ_UPDATING
while (this.buffered < this.highWaterMark && (stream._duplexState & SHOULD_NOT_READ) === 0) {
stream._duplexState |= READ_ACTIVE_AND_SYNC_AND_NEEDS_PUSH
stream._read(this.afterRead)
stream._duplexState &= READ_NOT_SYNC
if ((stream._duplexState & READ_ACTIVE) === 0) this.drain()
}
do {
this.drain()
if ((stream._duplexState & READ_READABLE_STATUS) === READ_EMIT_READABLE_AND_QUEUED) {
stream._duplexState |= READ_EMITTED_READABLE
stream.emit('readable')
}
while (this.buffered < this.highWaterMark && (stream._duplexState & SHOULD_NOT_READ) === 0) {
stream._duplexState |= READ_ACTIVE_AND_NEEDS_PUSH
stream._read(this.afterRead)
this.drain()
}
if ((stream._duplexState & READ_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary()
if ((stream._duplexState & READ_READABLE_STATUS) === READ_EMIT_READABLE_AND_QUEUED) {
stream._duplexState |= READ_EMITTED_READABLE
stream.emit('readable')
}
if ((stream._duplexState & READ_PRIMARY_AND_ACTIVE) === 0) this.updateNonPrimary()
} while (this.continueUpdate() === true)
stream._duplexState &= READ_NOT_UPDATING
}

@@ -383,6 +402,17 @@

continueUpdate () {
if ((this.stream._duplexState & READ_NEXT_TICK) === 0) return false
this.stream._duplexState &= READ_NOT_NEXT_TICK
return true
}
updateCallback () {
if ((this.stream._readableState & READ_UPDATE_SYNC_STATUS) === READ_PRIMARY) this.update()
else this.updateNextTick()
}
updateNextTick () {
if ((this.stream._duplexState & READ_NEXT_TICK) !== 0) return
this.stream._duplexState |= READ_NEXT_TICK
queueTick(this.afterUpdateNextTick)
if ((this.stream._duplexState & READ_UPDATING) === 0) queueTick(this.afterUpdateNextTick)
}

@@ -444,4 +474,3 @@ }

this.stream._duplexState |= READ_PIPE_DRAINED
if ((this.stream._duplexState & READ_ACTIVE_AND_SYNC) === 0) this.updateNextTick()
else this.drain()
this.updateCallback()
}

@@ -461,3 +490,6 @@

stream._duplexState &= WRITE_NOT_ACTIVE
this.update()
// no need to wait the extra tick here, so we short circuit that
if ((stream._duplexState & WRITE_UPDATING) === 0) this.update()
else this.updateNextTick()
}

@@ -499,3 +531,3 @@

if ((stream._duplexState & WRITE_SYNC) === 0) this.update()
this.updateCallback()
}

@@ -506,13 +538,17 @@

this.stream._duplexState &= READ_NOT_ACTIVE
if ((this.stream._duplexState & READ_SYNC) === 0) this.update()
this.updateCallback()
}
function updateReadNT () {
this.stream._duplexState &= READ_NOT_NEXT_TICK
this.update()
if ((this.stream._duplexState & READ_UPDATING) === 0) {
this.stream._duplexState &= READ_NOT_NEXT_TICK
this.update()
}
}
function updateWriteNT () {
this.stream._duplexState &= WRITE_NOT_NEXT_TICK
this.update()
if ((this.stream._duplexState & WRITE_UPDATING) === 0) {
this.stream._duplexState &= WRITE_NOT_NEXT_TICK
this.update()
}
}

@@ -544,7 +580,7 @@

if (stream._writableState !== null) {
stream._writableState.update()
stream._writableState.updateCallback()
}
if (stream._readableState !== null) {
stream._readableState.update()
stream._readableState.updateCallback()
}

@@ -609,4 +645,10 @@ }

if (this._readableState !== null) this._readableState.error = err
if (this._writableState !== null) this._writableState.error = err
if (this._readableState !== null) {
this._readableState.highWaterMark = 0
this._readableState.error = err
}
if (this._writableState !== null) {
this._writableState.highWaterMark = 0
this._writableState.error = err
}

@@ -663,4 +705,4 @@ this._duplexState |= PREDESTROYING

pipe (dest, cb) {
this._readableState.updateNextTick()
this._readableState.pipe(dest, cb)
this._readableState.updateNextTick()
return dest

@@ -667,0 +709,0 @@ }

{
"name": "streamx",
"version": "2.14.3",
"version": "2.15.0",
"description": "An iteration of the Node.js core streams with a series of improvements",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc