123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- import { EventEmitter } from 'events'
- import { Stream } from 'stream'
- export namespace Minipass {
- export type Encoding = BufferEncoding | 'buffer' | null
- export interface Writable extends EventEmitter {
- end(): any
- write(chunk: any, ...args: any[]): any
- }
- export interface Readable extends EventEmitter {
- pause(): any
- resume(): any
- pipe(): any
- }
- export type DualIterable<T> = Iterable<T> & AsyncIterable<T>
- export type ContiguousData =
- | Buffer
- | ArrayBufferLike
- | ArrayBufferView
- | string
- export type BufferOrString = Buffer | string
- export interface SharedOptions {
- async?: boolean
- signal?: AbortSignal
- }
- export interface StringOptions extends SharedOptions {
- encoding: BufferEncoding
- objectMode?: boolean
- }
- export interface BufferOptions extends SharedOptions {
- encoding?: null | 'buffer'
- objectMode?: boolean
- }
- export interface ObjectModeOptions extends SharedOptions {
- objectMode: true
- }
- export interface PipeOptions {
- end?: boolean
- proxyErrors?: boolean
- }
- export type Options<T> = T extends string
- ? StringOptions
- : T extends Buffer
- ? BufferOptions
- : ObjectModeOptions
- }
- export class Minipass<
- RType extends any = Buffer,
- WType extends any = RType extends Minipass.BufferOrString
- ? Minipass.ContiguousData
- : RType
- >
- extends Stream
- implements Minipass.DualIterable<RType>
- {
- static isStream(stream: any): stream is Minipass.Readable | Minipass.Writable
- readonly bufferLength: number
- readonly flowing: boolean
- readonly writable: boolean
- readonly readable: boolean
- readonly aborted: boolean
- readonly paused: boolean
- readonly emittedEnd: boolean
- readonly destroyed: boolean
-
- readonly objectMode: boolean
- async: boolean
-
- readonly encoding: Minipass.Encoding
-
-
- constructor(
- ...args: RType extends Buffer
- ? [] | [Minipass.Options<RType>]
- : [Minipass.Options<RType>]
- )
- write(chunk: WType, 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?: Minipass.Encoding, cb?: () => void): this
- pause(): void
- resume(): void
- promise(): Promise<void>
- collect(): Promise<RType[]>
- concat(): RType extends Minipass.BufferOrString ? Promise<RType> : never
- destroy(er?: any): void
- pipe<W extends Minipass.Writable>(dest: W, opts?: Minipass.PipeOptions): W
- unpipe<W extends Minipass.Writable>(dest: W): void
- /**
- * alias for on()
- */
- addEventHandler(event: string, listener: (...args: any[]) => any): this
- on(event: string, listener: (...args: any[]) => any): this
- on(event: 'data', listener: (chunk: RType) => any): this
- on(event: 'error', listener: (error: any) => any): this
- on(
- event:
- | 'readable'
- | 'drain'
- | 'resume'
- | 'end'
- | 'prefinish'
- | 'finish'
- | 'close',
- listener: () => any
- ): this
- [Symbol.iterator](): Generator<RType, void, void>
- [Symbol.asyncIterator](): AsyncGenerator<RType, void, void>
- }
|