diff --git a/package.json b/package.json index 1233be1..3946948 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "polendina": "^3.2.21", "semantic-release": "^25.0.3", "standard": "^17.1.2", - "typescript": "^6.0.3" + "typescript": "^7.0.2" }, "release": { "branches": [ diff --git a/types/through2.d.ts b/types/through2.d.ts index 57551eb..4d7b7f0 100644 --- a/types/through2.d.ts +++ b/types/through2.d.ts @@ -1,3 +1,17 @@ +/** + * @file Tiny utilities for inserting transformation logic into Node.js stream + * pipelines without subclassing `Transform`. Exports `transform`, + * `objectTransform`, `transformer`. See `through2/web` for the Web Streams + * variant. + */ +export type ClassicTransformFn = (chunk: any, encoding: BufferEncoding, callback: (err?: Error | null, data?: any) => void) => void; +export type AsyncTransformFn = (chunk: any, encoding: BufferEncoding) => any | Promise; +export type AsyncGenTransformFn = (source: AsyncIterable) => AsyncGenerator; +export type TransformFn = ClassicTransformFn | AsyncTransformFn | AsyncGenTransformFn; +export type ClassicFlushFn = (callback: (err?: Error | null) => void) => void; +export type AsyncFlushFn = () => any | Promise; +export type FlushFn = ClassicFlushFn | AsyncFlushFn; +export type TransformOptions = import('readable-stream').TransformOptions; /** * Build a Transform around a transformation function (classic / async / async * generator; auto-dispatched). @@ -23,7 +37,7 @@ * @param {FlushFn} [flushFn] * @returns {import('readable-stream').Transform} */ -export function transform(options?: TransformOptions | TransformFn, transformFn?: TransformFn, flushFn?: FlushFn): import("readable-stream").Transform; +export declare function transform(options?: TransformOptions | TransformFn, transformFn?: TransformFn, flushFn?: FlushFn): import('readable-stream').Transform; /** * Like {@link transform}, with `objectMode: true` by default. * @@ -44,7 +58,7 @@ export function transform(options?: TransformOptions | TransformFn, transformFn? * @param {FlushFn} [flushFn] * @returns {import('readable-stream').Transform} */ -export function objectTransform(options?: TransformOptions | TransformFn, transformFn?: TransformFn, flushFn?: FlushFn): import("readable-stream").Transform; +export declare function objectTransform(options?: TransformOptions | TransformFn, transformFn?: TransformFn, flushFn?: FlushFn): import('readable-stream').Transform; /** * Build a reusable factory. The returned function works with or without * `new`; per-call options merge over the configured defaults and are exposed @@ -67,18 +81,9 @@ export function objectTransform(options?: TransformOptions | TransformFn, transf * @param {FlushFn} [flushFn] * @returns {(override?: TransformOptions) => import('readable-stream').Transform & { options: TransformOptions }} */ -export function transformer(options?: TransformOptions | TransformFn, transformFn?: TransformFn, flushFn?: FlushFn): (override?: TransformOptions) => import("readable-stream").Transform & { +export declare function transformer(options?: TransformOptions | TransformFn, transformFn?: TransformFn, flushFn?: FlushFn): (override?: TransformOptions) => import('readable-stream').Transform & { options: TransformOptions; }; -export default through2; -export type ClassicTransformFn = (chunk: any, encoding: BufferEncoding, callback: (err?: Error | null, data?: any) => void) => void; -export type AsyncTransformFn = (chunk: any, encoding: BufferEncoding) => any | Promise; -export type AsyncGenTransformFn = (source: AsyncIterable) => AsyncGenerator; -export type TransformFn = ClassicTransformFn | AsyncTransformFn | AsyncGenTransformFn; -export type ClassicFlushFn = (callback: (err?: Error | null) => void) => void; -export type AsyncFlushFn = () => any | Promise; -export type FlushFn = ClassicFlushFn | AsyncFlushFn; -export type TransformOptions = import("readable-stream").TransformOptions; /** * Default export: `transform` with legacy `.obj` / `.ctor` for v4 * back-compatibility. @@ -88,4 +93,5 @@ declare const through2: typeof transform & { obj: typeof objectTransform; ctor: typeof transformer; }; +export default through2; //# sourceMappingURL=through2.d.ts.map \ No newline at end of file diff --git a/types/through2.d.ts.map b/types/through2.d.ts.map index e6d61a4..72f21b7 100644 --- a/types/through2.d.ts.map +++ b/types/through2.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"through2.d.ts","sourceRoot":"","sources":["../through2.js"],"names":[],"mappings":"AA6LA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,oCALW,gBAAgB,GAAG,WAAW,gBAC9B,WAAW,YACX,OAAO,GACL,OAAO,iBAAiB,EAAE,SAAS,CAO/C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0CALW,gBAAgB,GAAG,WAAW,gB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,WAAW,CAAE,OAAO,AALjC,CACA,EADQ,gBAAgB,GAAG,WAKM,EAAE,WAAW,AAJ9C,CACA,EADQ,WAIsC,EAAE,OAAO,AAHvD,CACA,EADQ,OAG+C,GAF7C,CAAC,QAAQ,CAAC,EAAE,gBAAgB,KAAK,OAAO,iBAAiB,EAAE,SAAS,GAAG;IAAE,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAahH;AAED;;;;GAIG;AACH,QAAA,MAAM,QAAQ,EAFJ,OAAO,SAAS,GAAG;IAAE,GAAG,EAAE,OAAO,eAAe,CAAC;IAAC,IAAI,EAAE,OAAO,WAAW,CAAA;CAErC,CAAA;eAIhC,QAAQ"} \ No newline at end of file diff --git a/types/web.d.ts b/types/web.d.ts index 8a3003d..be99939 100644 --- a/types/web.d.ts +++ b/types/web.d.ts @@ -1,3 +1,17 @@ +/** + * @file Tiny utility for inserting transformation logic into Web Streams + * pipelines. Returns `TransformStream` instances; zero runtime dependencies; + * runs anywhere `TransformStream` is a global (modern browsers, Node.js, + * Deno, Bun, Cloudflare Workers). See the root `through2` entry for the + * Node.js streams variant. + */ +export type ClassicWebTransformFn = (chunk: any, controller: TransformStreamDefaultController) => void; +export type AsyncWebTransformFn = (chunk: any) => any | Promise; +export type AsyncGenWebTransformFn = (source: AsyncIterable) => AsyncGenerator; +export type WebTransformFn = ClassicWebTransformFn | AsyncWebTransformFn | AsyncGenWebTransformFn; +export type ClassicWebFlushFn = (controller: TransformStreamDefaultController) => void; +export type AsyncWebFlushFn = () => any | Promise; +export type WebFlushFn = ClassicWebFlushFn | AsyncWebFlushFn; /** * Build a TransformStream around a transformation function (classic / * async / async generator; auto-dispatched). @@ -27,16 +41,9 @@ * @param {WebFlushFn} [flushFn] * @returns {{ readable: ReadableStream, writable: WritableStream }} */ -export function transform(transformFn?: WebTransformFn, flushFn?: WebFlushFn): { +export declare function transform(transformFn?: WebTransformFn, flushFn?: WebFlushFn): { readable: ReadableStream; writable: WritableStream; }; export default transform; -export type ClassicWebTransformFn = (chunk: any, controller: TransformStreamDefaultController) => void; -export type AsyncWebTransformFn = (chunk: any) => any | Promise; -export type AsyncGenWebTransformFn = (source: AsyncIterable) => AsyncGenerator; -export type WebTransformFn = ClassicWebTransformFn | AsyncWebTransformFn | AsyncGenWebTransformFn; -export type ClassicWebFlushFn = (controller: TransformStreamDefaultController) => void; -export type AsyncWebFlushFn = () => any | Promise; -export type WebFlushFn = ClassicWebFlushFn | AsyncWebFlushFn; //# sourceMappingURL=web.d.ts.map \ No newline at end of file diff --git a/types/web.d.ts.map b/types/web.d.ts.map index 12b2589..fb1345b 100644 --- a/types/web.d.ts.map +++ b/types/web.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../web.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wCAJW,cAAc,YACd,UAAU,GACR;IAAE,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,CAAA;CAAE,CA2C5E;;oCA3Fa,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,gCAAgC,CAAC,GAAG,CAAC,KAAK,IAAI;kCACvE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;qCAClC,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,KAAK,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;6BAC/D,qBAAqB,GAAG,mBAAmB,GAAG,sBAAsB;gCACpE,CAAC,UAAU,EAAE,gCAAgC,CAAC,GAAG,CAAC,KAAK,IAAI;8BAC3D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;yBACxB,iBAAiB,GAAG,eAAe"} \ No newline at end of file +{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../web.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEC,YAAmF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