From efe523db509c136097dfa2f05f032c6c129a853b Mon Sep 17 00:00:00 2001 From: Yasser Nascimento Date: Thu, 9 Jan 2025 09:31:42 -0300 Subject: [PATCH] Revert "Init TypeScript typings" This reverts commit 5ea70a0f6c92f5d3937a85cafc4a0806916048c8. --- index.d.ts | 240 --------------------------------------------------- package.json | 12 +-- 2 files changed, 1 insertion(+), 251 deletions(-) delete mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index a17a7af..0000000 --- a/index.d.ts +++ /dev/null @@ -1,240 +0,0 @@ -import EventEmitter from 'bare-events' -import Buffer, { BufferEncoding } from 'bare-buffer' - -// duplicated from 'bare-events' -declare interface EventMap { - [event: string | symbol]: unknown[] -} - -type StreamOptions = { - destroy?: Stream['_destroy'] - eagerOpen?: boolean - open?: Stream['_open'] - predestroy?: Stream['_predestroy'] - signal?: AbortSignal -} - -declare interface Stream - extends EventEmitter { - _open(cb: (err?: Error | null) => void): void - _destroy: ( - this: this, - err: Error | null, - cb: (err?: Error | null) => void - ) => void - _predestroy(): void - - get readable(): boolean - get writable(): boolean - get destroyed(): boolean - get destroying(): boolean - - destroy(err?: Error | null): void -} - -declare class Stream { - constructor(opts?: StreamOptions) -} - -type ReadableOptions = { - byteLength?: (data: unknown) => number - byteLengthReadable?: (data: unknown) => number - encoding?: BufferEncoding - highWaterMark?: number - map?: (data: unknown) => unknown - mapReadable?: (data: unknown) => unknown - read?: Readable['_read'] -} & StreamOptions - -declare interface Readable - extends Stream<{ - data: [data: T | null] - close: [] - end: [] - error: [err: Error] - readable: [] - piping: [dest: unknown] - }> { - _read(this: this, size: number): void - - push(chunk: T | null, encoding?: BufferEncoding): boolean - - unshift(chunk: T | null, encoding?: BufferEncoding): boolean - - read(): T | null - - resume(): this - pause(): this - - pipe(dest: A, cb?: (err: Error) => void): A - - setEncoding(encoding: BufferEncoding): void - - [Symbol.asyncIterator](): AsyncIterator -} - -declare class Readable { - static from(data: unknown | unknown[], opts?: ReadableOptions): Readable - - static isBackpressured(rs: Readable): boolean - static isPaused(rs: Readable): boolean - - constructor(opts?: ReadableOptions) -} - -type WritableOptions = { - final?: Writable['_final'] - mapWritable?: (data: unknown) => unknown - write?: Writable['_write'] - writev?: Writable['_writev'] -} & StreamOptions - -declare interface Writable - extends Stream<{ - drain: [] - finish: [] - close: [] - error: [err: Error] - pipe: [src: Readable] - }> { - readonly destroyed: boolean - - _writev(this: this, batch: T[], cb: (err?: Error | null) => void): void - _write( - this: this, - data: T, - encoding: BufferEncoding, - cb: (err?: Error | null) => void - ): void - _final(this: this, cb: (err?: Error | null) => void): void - - write(chunk: T, encoding?: BufferEncoding, cb?: () => void): boolean - write(chunk: T, cb?: () => void): boolean - - end(chunk: T, encoding?: BufferEncoding, cb?: () => void): this - end(chunk: T, cb?: () => void): this - end(cb?: () => void): this - - cork(): void - uncork(): void -} - -declare class Writable { - static isBackpressured(ws: Writable): Promise - static drained(ws: Writable): Promise - - constructor(opts?: WritableOptions) -} - -type DuplexOptions = ReadableOptions & WritableOptions - -declare interface Duplex - extends Stream<{ - close: [] - data: [data: T | null] - drain: [] - end: [] - error: [err: Error] - finish: [] - pipe: [src: Readable] - piping: [dest: unknown] - readable: [] - }> { - _read(this: this, size: number): void - _writev(this: this, batch: T[], cb: (err?: Error | null) => void): void - _write(this: this, data: T, cb: (err?: Error | null) => void): void - _final(this: this, cb: (err?: Error | null) => void): void - - write(chunk: T, encoding?: BufferEncoding, cb?: () => void): boolean - write(chunk: T, cb?: () => void): boolean - - end(chunk: T, encoding?: BufferEncoding, cb?: () => void): this - end(chunk: T, cb?: () => void): this - end(cb?: () => void): this - - push(chunk: T | null, encoding?: BufferEncoding): boolean - unshift(chunk: T | null, encoding?: BufferEncoding): boolean - - read(): T | null - - resume(): this - pause(): this - - pipe(dest: A, cb?: (err: Error) => void): A - - setEncoding(encoding: BufferEncoding): void - - cork(): void - uncork(): void - - [Symbol.asyncIterator](): AsyncIterator -} - -declare class Duplex { - constructor(opts?: DuplexOptions) -} - -type TransformOptions = { - flush?: Transform['_flush'] - transform?: Transform['_transform'] -} & DuplexOptions - -declare interface Transform extends Duplex { - _transform( - this: this, - data: T, - encoding: BufferEncoding, - cb: (err?: Error | null) => void - ): void - _flush(cb: (this: this, err: Error | null) => void): void -} - -declare class Transform { - constructor(opts?: TransformOptions) -} - -declare class Pipeline { - constructor(src: Stream, dst: Stream, cb: (err?: Error | null) => void) - - finished(): void - - done(stream: Stream, err: Error): void -} - -declare namespace Stream { - export { - Pipeline, - Stream, - Readable, - Writable, - Duplex, - Transform, - Transform as PassThrough - } - - export function finished( - stream: Stream, - opts: { cleanup?: boolean }, - cb: (err?: Error | null) => void - ): () => void - - export function finished( - stream: Stream, - cb: (err?: Error | null) => void - ): () => void - - export function isStream(stream: unknown): stream is Stream - - export function isEnded(stream: Stream): boolean - - export function isFinished(stream: Stream): boolean - - export function isDisturbed(stream: Stream): boolean - - export function getStreamError( - stream: Stream, - opts?: { all?: boolean } - ): Error | null -} - -export = Stream diff --git a/package.json b/package.json index 1c3fec8..7493b73 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,7 @@ "version": "2.6.1", "description": "Streaming data for JavaScript", "exports": { - ".": { - "types": "./index.d.ts", - "default": "./index.js" - }, + ".": "./index.js", "./package": "./package.json", "./promises": "./promises.js", "./web": "./web.js", @@ -14,7 +11,6 @@ }, "files": [ "index.js", - "index.d.ts", "promises.js", "web.js", "global.js" @@ -36,14 +32,8 @@ "streamx": "^2.21.0" }, "devDependencies": { - "bare-buffer": "^2.7.1", - "bare-events": "^2.5.3", "brittle": "^3.5.2", "prettier": "^3.3.3", "prettier-config-standard": "^7.0.0" - }, - "peerDependencies": { - "bare-buffer": "*", - "bare-events": "*" } }