Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
deps: minipass@4.0.0
  • Loading branch information
lukekarrys committed Dec 7, 2022
1 parent 6b77340 commit 0a3fe00
Show file tree
Hide file tree
Showing 49 changed files with 4,775 additions and 2,063 deletions.
43 changes: 25 additions & 18 deletions node_modules/.gitignore
Expand Up @@ -52,9 +52,6 @@
!/brace-expansion
!/builtins
!/cacache
!/cacache/node_modules/
/cacache/node_modules/*
!/cacache/node_modules/minipass
!/chalk
!/chownr
!/ci-info
Expand Down Expand Up @@ -88,6 +85,9 @@
!/events
!/fastest-levenshtein
!/fs-minipass
!/fs-minipass/node_modules/
/fs-minipass/node_modules/*
!/fs-minipass/node_modules/minipass
!/fs.realpath
!/function-bind
!/gauge
Expand Down Expand Up @@ -136,18 +136,36 @@
!/libnpmversion
!/lru-cache
!/make-fetch-happen
!/make-fetch-happen/node_modules/
/make-fetch-happen/node_modules/*
!/make-fetch-happen/node_modules/minipass
!/minimatch
!/minipass-collect
!/minipass-collect/node_modules/
/minipass-collect/node_modules/*
!/minipass-collect/node_modules/minipass
!/minipass-fetch
!/minipass-fetch/node_modules/
/minipass-fetch/node_modules/*
!/minipass-fetch/node_modules/minipass
!/minipass-flush
!/minipass-flush/node_modules/
/minipass-flush/node_modules/*
!/minipass-flush/node_modules/minipass
!/minipass-json-stream
!/minipass-json-stream/node_modules/
/minipass-json-stream/node_modules/*
!/minipass-json-stream/node_modules/minipass
!/minipass-pipeline
!/minipass-pipeline/node_modules/
/minipass-pipeline/node_modules/*
!/minipass-pipeline/node_modules/minipass
!/minipass-sized
!/minipass-sized/node_modules/
/minipass-sized/node_modules/*
!/minipass-sized/node_modules/minipass
!/minipass
!/minizlib
!/minizlib/node_modules/
/minizlib/node_modules/*
!/minizlib/node_modules/minipass
!/mkdirp
!/ms
!/mute-stream
Expand All @@ -173,6 +191,7 @@
!/node-gyp/node_modules/make-fetch-happen
!/node-gyp/node_modules/minimatch
!/node-gyp/node_modules/minipass-fetch
!/node-gyp/node_modules/minipass
!/node-gyp/node_modules/nopt
!/node-gyp/node_modules/npmlog
!/node-gyp/node_modules/ssri
Expand All @@ -190,17 +209,11 @@
!/npm-pick-manifest
!/npm-profile
!/npm-registry-fetch
!/npm-registry-fetch/node_modules/
/npm-registry-fetch/node_modules/*
!/npm-registry-fetch/node_modules/minipass
!/npm-user-validate
!/npmlog
!/once
!/p-map
!/pacote
!/pacote/node_modules/
/pacote/node_modules/*
!/pacote/node_modules/minipass
!/parse-conflict-json
!/path-is-absolute
!/postcss-selector-parser
Expand Down Expand Up @@ -240,17 +253,11 @@
!/spdx-expression-parse
!/spdx-license-ids
!/ssri
!/ssri/node_modules/
/ssri/node_modules/*
!/ssri/node_modules/minipass
!/string_decoder
!/string-width
!/strip-ansi
!/supports-color
!/tar
!/tar/node_modules/
/tar/node_modules/*
!/tar/node_modules/minipass
!/text-table
!/tiny-relative-date
!/treeverse
Expand Down
@@ -1,8 +1,4 @@
/// <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'
import { Stream } from 'stream'

Expand All @@ -20,6 +16,12 @@ declare namespace Minipass {
pipe(): any
}

interface Pipe<R, W> {
src: Minipass<R, W>
dest: Writable
opts: PipeOptions
}

type DualIterable<T> = Iterable<T> & AsyncIterable<T>

type ContiguousData = Buffer | ArrayBufferLike | ArrayBufferView | string
Expand Down Expand Up @@ -74,6 +76,12 @@ declare class Minipass<
readonly emittedEnd: boolean
readonly destroyed: boolean

/**
* 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,
* so is not safe to do in TypeScript.
Expand Down
Expand Up @@ -21,8 +21,6 @@ const DECODER = Symbol('decoder')
const FLOWING = Symbol('flowing')
const PAUSED = Symbol('paused')
const RESUME = Symbol('resume')
const BUFFER = Symbol('buffer')
const PIPES = Symbol('pipes')
const BUFFERLENGTH = Symbol('bufferLength')
const BUFFERPUSH = Symbol('bufferPush')
const BUFFERSHIFT = Symbol('bufferShift')
Expand Down Expand Up @@ -96,8 +94,8 @@ module.exports = class Minipass extends Stream {
this[FLOWING] = false
// whether we're explicitly paused
this[PAUSED] = false
this[PIPES] = []
this[BUFFER] = []
this.pipes = []
this.buffer = []
this[OBJECTMODE] = options && options.objectMode || false
if (this[OBJECTMODE])
this[ENCODING] = null
Expand All @@ -116,12 +114,6 @@ module.exports = class Minipass extends Stream {
this.readable = true
this[BUFFERLENGTH] = 0
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] })
}
}

get bufferLength () { return this[BUFFERLENGTH] }
Expand All @@ -137,8 +129,8 @@ module.exports = class Minipass extends Stream {

if (this[ENCODING] !== enc) {
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))
}

this[ENCODING] = enc
Expand Down Expand Up @@ -260,14 +252,14 @@ module.exports = class Minipass extends Stream {
if (this[OBJECTMODE])
n = null

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]()
return ret
}
Expand All @@ -276,14 +268,14 @@ module.exports = class Minipass extends Stream {
if (n === chunk.length || n === null)
this[BUFFERSHIFT]()
else {
this[BUFFER][0] = chunk.slice(n)
this.buffer[0] = chunk.slice(n)
chunk = chunk.slice(0, n)
this[BUFFERLENGTH] -= n
}

this.emit('data', chunk)

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

return chunk
Expand Down Expand Up @@ -318,7 +310,7 @@ module.exports = class Minipass extends Stream {
this[PAUSED] = false
this[FLOWING] = true
this.emit('resume')
if (this[BUFFER].length)
if (this.buffer.length)
this[FLUSH]()
else if (this[EOF])
this[MAYBE_EMIT_END]()
Expand Down Expand Up @@ -352,23 +344,23 @@ module.exports = class Minipass extends Stream {
this[BUFFERLENGTH] += 1
else
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()
}

[FLUSH] (noDrain) {
do {} while (this[FLUSHCHUNK](this[BUFFERSHIFT]()))

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

Expand All @@ -393,7 +385,7 @@ module.exports = class Minipass extends Stream {
if (opts.end)
dest.end()
} 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))
if (this[ASYNC])
defer(() => this[RESUME]())
Expand All @@ -405,9 +397,9 @@ module.exports = class Minipass extends Stream {
}

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()
}
}
Expand All @@ -418,7 +410,7 @@ module.exports = class Minipass extends Stream {

on (ev, fn) {
const ret = super.on(ev, fn)
if (ev === 'data' && !this[PIPES].length && !this.flowing)
if (ev === 'data' && !this.pipes.length && !this.flowing)
this[RESUME]()
else if (ev === 'readable' && this[BUFFERLENGTH] !== 0)
super.emit('readable')
Expand All @@ -442,7 +434,7 @@ module.exports = class Minipass extends Stream {
if (!this[EMITTING_END] &&
!this[EMITTED_END] &&
!this[DESTROYED] &&
this[BUFFER].length === 0 &&
this.buffer.length === 0 &&
this[EOF]) {
this[EMITTING_END] = true
this.emit('end')
Expand Down Expand Up @@ -494,7 +486,7 @@ module.exports = class Minipass extends Stream {
}

[EMITDATA] (data) {
for (const p of this[PIPES]) {
for (const p of this.pipes) {
if (p.dest.write(data) === false)
this.pause()
}
Expand All @@ -519,14 +511,14 @@ module.exports = class Minipass extends Stream {
if (this[DECODER]) {
const data = this[DECODER].end()
if (data) {
for (const p of this[PIPES]) {
for (const p of this.pipes) {
p.dest.write(data)
}
super.emit('data', data)
}
}

for (const p of this[PIPES]) {
for (const p of this.pipes) {
p.end()
}
const ret = super.emit('end')
Expand Down Expand Up @@ -633,7 +625,7 @@ module.exports = class Minipass extends Stream {
this[DESTROYED] = true

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

if (typeof this.close === 'function' && !this[CLOSED])
Expand Down
@@ -1,6 +1,6 @@
{
"name": "minipass",
"version": "4.0.0",
"version": "3.3.6",
"description": "minimal implementation of a PassThrough stream",
"main": "index.js",
"types": "index.d.ts",
Expand Down
@@ -1,8 +1,4 @@
/// <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'
import { Stream } from 'stream'

Expand All @@ -20,6 +16,12 @@ declare namespace Minipass {
pipe(): any
}

interface Pipe<R, W> {
src: Minipass<R, W>
dest: Writable
opts: PipeOptions
}

type DualIterable<T> = Iterable<T> & AsyncIterable<T>

type ContiguousData = Buffer | ArrayBufferLike | ArrayBufferView | string
Expand Down Expand Up @@ -74,6 +76,12 @@ declare class Minipass<
readonly emittedEnd: boolean
readonly destroyed: boolean

/**
* 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,
* so is not safe to do in TypeScript.
Expand Down

0 comments on commit 0a3fe00

Please sign in to comment.