Socket
Socket
Sign inDemoInstall

minipass

Package Overview
Dependencies
1
Maintainers
6
Versions
94
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.3.6 to 4.0.0

16

index.d.ts
/// <reference types="node" />
// Note: marking anything protected or private in the exported
// class will limit Minipass's ability to be used as the base
// for mixin classes.
import { EventEmitter } from 'events'

@@ -19,8 +23,2 @@ import { Stream } from 'stream'

interface Pipe<R, W> {
src: Minipass<R, W>
dest: Writable
opts: PipeOptions
}
type DualIterable<T> = Iterable<T> & AsyncIterable<T>

@@ -81,8 +79,2 @@

/**
* Not technically private or readonly, but not safe to mutate.
*/
private readonly buffer: RType[]
private readonly pipes: Minipass.Pipe<RType, WType>[]
/**
* Technically writable, but mutating it can change the type,

@@ -89,0 +81,0 @@ * so is not safe to do in TypeScript.

@@ -24,2 +24,4 @@ 'use strict'

const RESUME = Symbol('resume')
const BUFFER = Symbol('buffer')
const PIPES = Symbol('pipes')
const BUFFERLENGTH = Symbol('bufferLength')

@@ -98,4 +100,4 @@ const BUFFERPUSH = Symbol('bufferPush')

this[PAUSED] = false
this.pipes = []
this.buffer = []
this[PIPES] = []
this[BUFFER] = []
this[OBJECTMODE] = options && options.objectMode || false

@@ -119,2 +121,8 @@ if (this[OBJECTMODE])

this[DESTROYED] = false
if (options && options.debugExposeBuffer === true) {
Object.defineProperty(this, 'buffer', { get: () => this[BUFFER] })
}
if (options && options.debugExposePipes === true) {
Object.defineProperty(this, 'pipes', { get: () => this[PIPES] })
}
}

@@ -135,4 +143,4 @@

this[DECODER] = enc ? new SD(enc) : null
if (this.buffer.length)
this.buffer = this.buffer.map(chunk => this[DECODER].write(chunk))
if (this[BUFFER].length)
this[BUFFER] = this[BUFFER].map(chunk => this[DECODER].write(chunk))
}

@@ -259,10 +267,10 @@

if (this.buffer.length > 1 && !this[OBJECTMODE]) {
if (this[BUFFER].length > 1 && !this[OBJECTMODE]) {
if (this.encoding)
this.buffer = [this.buffer.join('')]
this[BUFFER] = [this[BUFFER].join('')]
else
this.buffer = [Buffer.concat(this.buffer, this[BUFFERLENGTH])]
this[BUFFER] = [Buffer.concat(this[BUFFER], this[BUFFERLENGTH])]
}
const ret = this[READ](n || null, this.buffer[0])
const ret = this[READ](n || null, this[BUFFER][0])
this[MAYBE_EMIT_END]()

@@ -276,3 +284,3 @@ return ret

else {
this.buffer[0] = chunk.slice(n)
this[BUFFER][0] = chunk.slice(n)
chunk = chunk.slice(0, n)

@@ -284,3 +292,3 @@ this[BUFFERLENGTH] -= n

if (!this.buffer.length && !this[EOF])
if (!this[BUFFER].length && !this[EOF])
this.emit('drain')

@@ -320,3 +328,3 @@

this.emit('resume')
if (this.buffer.length)
if (this[BUFFER].length)
this[FLUSH]()

@@ -355,13 +363,13 @@ else if (this[EOF])

this[BUFFERLENGTH] += chunk.length
this.buffer.push(chunk)
this[BUFFER].push(chunk)
}
[BUFFERSHIFT] () {
if (this.buffer.length) {
if (this[BUFFER].length) {
if (this[OBJECTMODE])
this[BUFFERLENGTH] -= 1
else
this[BUFFERLENGTH] -= this.buffer[0].length
this[BUFFERLENGTH] -= this[BUFFER][0].length
}
return this.buffer.shift()
return this[BUFFER].shift()
}

@@ -372,3 +380,3 @@

if (!noDrain && !this.buffer.length && !this[EOF])
if (!noDrain && !this[BUFFER].length && !this[EOF])
this.emit('drain')

@@ -398,3 +406,3 @@ }

} else {
this.pipes.push(!opts.proxyErrors ? new Pipe(this, dest, opts)
this[PIPES].push(!opts.proxyErrors ? new Pipe(this, dest, opts)
: new PipeProxyErrors(this, dest, opts))

@@ -411,5 +419,5 @@ if (this[ASYNC])

unpipe (dest) {
const p = this.pipes.find(p => p.dest === dest)
const p = this[PIPES].find(p => p.dest === dest)
if (p) {
this.pipes.splice(this.pipes.indexOf(p), 1)
this[PIPES].splice(this[PIPES].indexOf(p), 1)
p.unpipe()

@@ -425,3 +433,3 @@ }

const ret = super.on(ev, fn)
if (ev === 'data' && !this.pipes.length && !this.flowing)
if (ev === 'data' && !this[PIPES].length && !this.flowing)
this[RESUME]()

@@ -450,3 +458,3 @@ else if (ev === 'readable' && this[BUFFERLENGTH] !== 0)

!this[DESTROYED] &&
this.buffer.length === 0 &&
this[BUFFER].length === 0 &&
this[EOF]) {

@@ -503,3 +511,3 @@ this[EMITTING_END] = true

[EMITDATA] (data) {
for (const p of this.pipes) {
for (const p of this[PIPES]) {
if (p.dest.write(data) === false)

@@ -529,3 +537,3 @@ this.pause()

if (data) {
for (const p of this.pipes) {
for (const p of this[PIPES]) {
p.dest.write(data)

@@ -537,3 +545,3 @@ }

for (const p of this.pipes) {
for (const p of this[PIPES]) {
p.end()

@@ -645,3 +653,3 @@ }

// throw away all buffered data, it's never coming out
this.buffer.length = 0
this[BUFFER].length = 0
this[BUFFERLENGTH] = 0

@@ -648,0 +656,0 @@

{
"name": "minipass",
"version": "3.3.6",
"version": "4.0.0",
"description": "minimal implementation of a PassThrough stream",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc