Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: isaacs/minipass
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 66a65348ec33823db3f8dc90e5a60348eb2da600
Choose a base ref
...
head repository: isaacs/minipass
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 52ab642fa447419dca139ce29fad780dd61a27af
Choose a head ref
  • 5 commits
  • 3 files changed
  • 2 contributors

Commits on Jul 24, 2022

  1. Change ES6 exports to CommonJS in index.d.ts

    The acutal library uses CommonJS exports (`module.exports =`), but the
    type definitions use ES6 exports (`export` and `export default`
    keywords). This changes the types to use the `export =` syntax to match
    the library.
    
    PR-URL: #41
    Credit: @MysteryBlokHed
    Close: #41
    Reviewed-by: @Timothy-Dement
    MysteryBlokHed authored and isaacs committed Jul 24, 2022
    2

    Verified

    This commit was signed with the committer’s verified signature.
    bagder Daniel Stenberg
    Copy the full SHA
    540540f View commit details
  2. 3.3.5

    isaacs committed Jul 24, 2022
    Copy the full SHA
    e5b768d View commit details

Commits on Sep 2, 2022

  1. Copy the full SHA
    47e7528 View commit details

Commits on Nov 25, 2022

  1. just publish as latest

    Stop issues like #41 from happening every publish
    
    Fix: #41
    isaacs committed Nov 25, 2022
    Copy the full SHA
    71eace9 View commit details
  2. 3.3.6

    isaacs committed Nov 25, 2022
    Copy the full SHA
    52ab642 View commit details
Showing with 74 additions and 67 deletions.
  1. +69 −63 index.d.ts
  2. +2 −2 package-lock.json
  3. +3 −2 package.json
132 changes: 69 additions & 63 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -2,39 +2,71 @@
import { EventEmitter } from 'events'
import { Stream } from 'stream'

export type Encoding = BufferEncoding | 'buffer' | null

interface Writable extends EventEmitter {
end(): any
write(chunk: any, ...args: any[]): any
}

interface Readable extends EventEmitter {
pause(): any
resume(): any
pipe(): any
}

interface Pipe<R, W> {
src: Minipass<R, W>
dest: Writable
opts: PipeOptions
declare namespace Minipass {
type Encoding = BufferEncoding | 'buffer' | null

interface Writable extends EventEmitter {
end(): any
write(chunk: any, ...args: any[]): any
}

interface Readable extends EventEmitter {
pause(): any
resume(): any
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

type BufferOrString = Buffer | string

interface StringOptions {
encoding: BufferEncoding
objectMode?: boolean
async?: boolean
}

interface BufferOptions {
encoding?: null | 'buffer'
objectMode?: boolean
async?: boolean
}

interface ObjectModeOptions {
objectMode: true
async?: boolean
}

interface PipeOptions {
end?: boolean
proxyErrors?: boolean
}

type Options<T> = T extends string
? StringOptions
: T extends Buffer
? BufferOptions
: ObjectModeOptions
}

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

type ContiguousData = Buffer | ArrayBufferLike | ArrayBufferView | string

type BufferOrString = Buffer | string

export default class Minipass<
declare class Minipass<
RType extends any = Buffer,
WType extends any = RType extends BufferOrString ? ContiguousData : RType
WType extends any = RType extends Minipass.BufferOrString
? Minipass.ContiguousData
: RType
>
extends Stream
implements DualIterable<RType>
implements Minipass.DualIterable<RType>
{
static isStream(stream: any): stream is Readable | Writable
static isStream(stream: any): stream is Minipass.Readable | Minipass.Writable

readonly bufferLength: number
readonly flowing: boolean
@@ -48,7 +80,7 @@ export default class Minipass<
* Not technically private or readonly, but not safe to mutate.
*/
private readonly buffer: RType[]
private readonly pipes: Pipe<RType, WType>[]
private readonly pipes: Minipass.Pipe<RType, WType>[]

/**
* Technically writable, but mutating it can change the type,
@@ -70,31 +102,31 @@ export default class Minipass<
* TypeScript does not provide many options for changing the type of
* an object at run-time, which is what changing the encoding does.
*/
readonly encoding: Encoding
readonly encoding: Minipass.Encoding
// setEncoding(encoding: Encoding): void

// Options required if not reading buffers
constructor(
...args: RType extends Buffer
? [] | [Options<RType>]
: [Options<RType>]
? [] | [Minipass.Options<RType>]
: [Minipass.Options<RType>]
)

write(chunk: WType, cb?: () => void): boolean
write(chunk: WType, encoding?: Encoding, cb?: () => void): boolean
write(chunk: WType, encoding?: Minipass.Encoding, cb?: () => void): boolean
read(size?: number): RType
end(cb?: () => void): this
end(chunk: any, cb?: () => void): this
end(chunk: any, encoding?: Encoding, cb?: () => void): this
end(chunk: any, encoding?: Minipass.Encoding, cb?: () => void): this
pause(): void
resume(): void
promise(): Promise<void>
collect(): Promise<RType[]>

concat(): RType extends BufferOrString ? Promise<RType> : never
concat(): RType extends Minipass.BufferOrString ? Promise<RType> : never
destroy(er?: any): void
pipe<W extends Writable>(dest: W, opts?: PipeOptions): W
unpipe<W extends Writable>(dest: W): void
pipe<W extends Minipass.Writable>(dest: W, opts?: Minipass.PipeOptions): W
unpipe<W extends Minipass.Writable>(dest: W): void

/**
* alias for on()
@@ -120,30 +152,4 @@ export default class Minipass<
[Symbol.asyncIterator](): AsyncIterator<RType>
}

interface StringOptions {
encoding: BufferEncoding
objectMode?: boolean
async?: boolean
}

interface BufferOptions {
encoding?: null | 'buffer'
objectMode?: boolean
async?: boolean
}

interface ObjectModeOptions {
objectMode: true
async?: boolean
}

export declare interface PipeOptions {
end?: boolean
proxyErrors?: boolean
}

export declare type Options<T> = T extends string
? StringOptions
: T extends Buffer
? BufferOptions
: ObjectModeOptions
export = Minipass
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "minipass",
"version": "3.3.4",
"version": "3.3.6",
"description": "minimal implementation of a PassThrough stream",
"main": "index.js",
"types": "index.d.ts",
"dependencies": {
"yallist": "^4.0.0"
},
@@ -18,7 +19,7 @@
"scripts": {
"test": "tap",
"preversion": "npm test",
"postversion": "npm publish --tag=next",
"postversion": "npm publish",
"postpublish": "git push origin --follow-tags"
},
"repository": {