yield-stream
Advanced tools
Comparing version 2.0.4 to 2.1.0
@@ -8,3 +8,3 @@ import { GeneratorFn, StreamGenerator } from "./types"; | ||
*/ | ||
export declare const compose: <T>(...generators: GeneratorFn<T>[]) => GeneratorFn<T>; | ||
export declare const compose: <Chunk>(...generators: GeneratorFn<Chunk>[]) => GeneratorFn<Chunk>; | ||
/** | ||
@@ -14,19 +14,19 @@ * Accepts a stream and transforms and returns a stream of the transformed | ||
*/ | ||
export declare const pipeline: <T>(stream: ReadableStream<T>, ...transforms: GeneratorFn<T>[]) => ReadableStream<T>; | ||
export declare const pipeline: <Chunk>(stream: ReadableStream<Chunk>, ...transforms: GeneratorFn<Chunk>[]) => ReadableStream<Chunk>; | ||
/** | ||
* Accepts a stream and yields all of its chunks. | ||
*/ | ||
export declare const yieldStream: <T>(stream: ReadableStream<T>, controller?: AbortController) => AsyncGenerator<Awaited<T>, void, unknown>; | ||
export declare const yieldStream: <Chunk>(stream: ReadableStream<Chunk>, controller?: AbortController) => AsyncGenerator<Awaited<Chunk>, void, unknown>; | ||
/** | ||
* Accepts a generator function and streams its outputs. | ||
*/ | ||
export declare const generateStream: <T, TReturn, D>(G: StreamGenerator<D, T, TReturn>, data?: D | undefined) => ReadableStream<T>; | ||
export declare const generateStream: <Chunk, Return, Data>(G: StreamGenerator<Data, Chunk, Return>, data?: Data | undefined) => ReadableStream<Chunk>; | ||
/** | ||
* Accepts an array and returns a stream of its items. | ||
*/ | ||
export declare const streamArray: <T>(array: T[]) => ReadableStream<T>; | ||
export declare const streamArray: <Chunk>(array: Chunk[]) => ReadableStream<Chunk>; | ||
/** | ||
* Accepts a stream and yields a growing buffer of all chunks received. | ||
*/ | ||
export declare const buffer: <T>(stream: ReadableStream<T>) => AsyncGenerator<T[], void, unknown>; | ||
export declare const buffer: <Chunk>(stream: ReadableStream<Chunk>) => AsyncGenerator<Chunk[], void, unknown>; | ||
export * from "./types"; |
@@ -1,1 +0,1 @@ | ||
const s=(...r)=>r.reduce((e,t)=>async function*(a){for await(const n of e(a))yield*t(n)}),T=(r,...e)=>{const t=s(...e);return c(async function*(){for await(const a of o(r))yield*t(a)})},o=async function*(r,e){const t=r.getReader();for(;!e?.signal.aborted;){const{done:a,value:n}=await t.read();if(a)break;yield n}},c=(r,e)=>new ReadableStream({async start(t){for await(const a of r(e))t.enqueue(a);t.close()}}),d=r=>c(function*(){for(const e of r)yield e}),l=async function*(r){const e=[];for await(const t of o(r))e.push(t),yield e};export*from"./types.js";export{l as buffer,s as compose,c as generateStream,T as pipeline,d as streamArray,o as yieldStream}; | ||
const c=(...n)=>n.reduce((e,t)=>async function*(r){for await(const a of e(r))yield*t(a)}),i=(n,...e)=>{const t=c(...e);return u(async function*(){for await(const r of o(n))yield*t(r)})},o=async function*(n,e){const t=n.getReader();for(;!e?.signal.aborted;){const{done:r,value:a}=await t.read();if(r)break;yield a}},u=(n,e)=>new ReadableStream({async start(t){for await(const r of n(e))t.enqueue(r);t.close()}}),f=n=>u(function*(){for(const e of n)yield e}),d=async function*(n){const e=[];for await(const t of o(n))e.push(t),yield e};export*from"./types.js";export{d as buffer,c as compose,u as generateStream,i as pipeline,f as streamArray,o as yieldStream}; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
export type GeneratorFn<T> = (data?: T) => Generator<T> | AsyncGenerator<T>; | ||
export type GeneratorFn<Data> = (data?: Data) => Generator<Data> | AsyncGenerator<Data>; | ||
/** | ||
@@ -11,3 +11,3 @@ * A generator function that receives a chunk of data and returns a generator | ||
*/ | ||
export type StreamGenerator<D, T, TReturn> = ((data?: D) => AsyncGenerator<T, TReturn>) | ((data?: D) => Generator<T, TReturn>); | ||
export type StreamGenerator<Data, Chunk, Return> = ((data?: Data) => AsyncGenerator<Chunk, Return>) | ((data?: Data) => Generator<Chunk, Return>); | ||
/** | ||
@@ -14,0 +14,0 @@ * Composes multiple generator functions into a single generator function. |
{ | ||
"name": "yield-stream", | ||
"version": "2.0.4", | ||
"version": "2.1.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7130