@soffinal/stream 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -2,17 +2,17 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/stream.ts", "../src/transformers/filter.ts", "../src/transformers/map.ts", "../src/transformers/merge.ts", "../src/transformers/flat.ts", "../src/reactive/list.ts", "../src/reactive/map.ts", "../src/reactive/set.ts", "../src/reactive/state.ts"],
4
4
  "sourcesContent": [
5
- "export type ValueOf<STREAM> = STREAM extends Stream<infer VALUE> ? VALUE : never;\nexport type FunctionGenerator<VALUE> = () => AsyncGenerator<VALUE, void>;\n/**\n * A reactive streaming library that provides async-first data structures with built-in event streams.\n *\n * @template VALUE - The type of values that flow through the stream\n *\n * @example\n * ```typescript\n * // Basic usage\n * const stream = new Stream<number>();\n * stream.listen(value => console.log(value));\n * stream.push(1, 2, 3);\n *\n * // With async generator\n * const timerStream = new Stream(async function* () {\n * let count = 0;\n * while (count < 5) {\n * yield count++;\n * await new Promise(resolve => setTimeout(resolve, 1000));\n * }\n * });\n *\n * // Async iteration\n * for await (const value of stream) {\n * console.log(value);\n * if (value === 10) break;\n * }\n * ```\n *\n * @example\n * // 📦 COPY-PASTE TRANSFORMERS LIBRARY - Essential transformers for immediate use\n *\n * // FILTERING TRANSFORMERS\n * const simpleFilter = <T>(predicate: (value: T) => boolean | Promise<boolean>) =>\n * filter<T, {}>({}, async (_, value) => {\n * const shouldPass = await predicate(value);\n * return [shouldPass, {}];\n * });\n *\n * const take = <T>(n: number) =>\n * filter<T, { count: number }>({ count: 0 }, (state, value) => {\n * if (state.count >= n) return;\n * return [true, { count: state.count + 1 }];\n * });\n *\n * const distinct = <T>() =>\n * filter<T, { seen: Set<T> }>({ seen: new Set() }, (state, value) => {\n * if (state.seen.has(value)) return [false, state];\n * state.seen.add(value);\n * return [true, state];\n * });\n *\n * const tap = <T>(fn: (value: T) => void | Promise<void>) =>\n * filter<T, {}>({}, async (_, value) => {\n * await fn(value);\n * return [true, {}];\n * });\n *\n * // MAPPING TRANSFORMERS\n * const simpleMap = <T, U>(fn: (value: T) => U | Promise<U>) =>\n * map<T, {}, U>({}, async (_, value) => {\n * const result = await fn(value);\n * return [result, {}];\n * });\n *\n * const withIndex = <T>() =>\n * map<T, { index: number }, { value: T; index: number }>(\n * { index: 0 },\n * (state, value) => [\n * { value, index: state.index },\n * { index: state.index + 1 }\n * ]\n * );\n *\n * const delay = <T>(ms: number) =>\n * map<T, {}, T>({}, async (_, value) => {\n * await new Promise(resolve => setTimeout(resolve, ms));\n * return [value, {}];\n * });\n *\n * const scan = <T, U>(fn: (acc: U, value: T) => U, initial: U) =>\n * map<T, { acc: U }, U>({ acc: initial }, (state, value) => {\n * const newAcc = fn(state.acc, value);\n * return [newAcc, { acc: newAcc }];\n * });\n *\n * // STATE CONVERTER\n * const toState = <T>(initialValue: T) => (stream: Stream<T>) => {\n * return new State(initialValue, stream);\n * };\n *\n * // Usage: stream.pipe(simpleFilter(x => x > 0)).pipe(take(5)).pipe(toState(0));\n */\nexport class Stream<VALUE = unknown> implements AsyncIterable<VALUE> {\n protected _listeners: Set<(value: VALUE) => void> = new Set<(value: VALUE) => void>();\n protected _generatorFn: FunctionGenerator<VALUE> | undefined;\n protected _generator: AsyncGenerator<VALUE, void> | undefined;\n protected _listenerAdded: Stream<void> | undefined;\n protected _listenerRemoved: Stream<void> | undefined;\n\n /**\n * Creates a new Stream instance.\n *\n * @param generatorFn - Optional async generator function to produce values you can use it for creating stream with custom transformation\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * // Empty stream\n * const stream = new Stream<string>();\n *\n * // Stream with generator\n * const countdown = new Stream(async function* () {\n * for (let i = 5; i > 0; i--) {\n * yield i;\n * await new Promise(resolve => setTimeout(resolve, 1000));\n * }\n * });\n *\n * // Stream with custom transformer\n * function filter<VALUE>(source:Stream<VALUE>,predicate:(value:VALUE) => boolean):Stream<VALUE>{\n * return new Stream<VALUE>(async function* () {\n * for await (const value of source) {\n * if (predicate(value)) yield value ;\n * }\n * });\n * }\n * const source = new Stream<number>();\n * const even = filter(source,v=> v % 2 === 0)\n * even.listen(console.log);\n * source.push(1, 2, 3, 4); // 2,4\n * ```\n */\n constructor();\n constructor(stream: FunctionGenerator<VALUE> | Stream<VALUE>);\n constructor(stream?: FunctionGenerator<VALUE> | Stream<VALUE>) {\n this._generatorFn = stream instanceof Stream ? () => stream[Symbol.asyncIterator]() : stream;\n }\n\n /**\n * Returns true if the stream has active listeners.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n * console.log(stream.hasListeners); // false\n *\n * const cleanup = stream.listen(value => console.log(value));\n * console.log(stream.hasListeners); // true\n *\n * cleanup();\n * console.log(stream.hasListeners); // false\n * ```\n */\n get hasListeners(): boolean {\n return this._listeners.size > 0;\n }\n\n /**\n * Stream that emits when a listener is added.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n * stream.listenerAdded.listen(() => console.log('Listener added'));\n *\n * stream.listen(value => console.log(value)); // Triggers 'Listener added'\n * ```\n */\n get listenerAdded(): Stream<void> {\n if (!this._listenerAdded) this._listenerAdded = new Stream<void>();\n return this._listenerAdded;\n }\n\n /**\n * Stream that emits when a listener is removed.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n * stream.listenerRemoved.listen(() => console.log('Listener removed'));\n *\n * const cleanup = stream.listen(value => console.log(value));\n * cleanup(); // Triggers 'Listener removed'\n * ```\n */\n get listenerRemoved(): Stream<void> {\n if (!this._listenerRemoved) this._listenerRemoved = new Stream<void>();\n return this._listenerRemoved;\n }\n async *[Symbol.asyncIterator](): AsyncGenerator<VALUE, void> {\n const queue: VALUE[] = [];\n let resolver: Function | undefined;\n\n const abort = this.listen((value) => {\n queue.push(value);\n resolver?.();\n });\n\n try {\n while (true) {\n if (queue.length) yield queue.shift()!;\n else await new Promise<void>((resolve) => (resolver = resolve));\n }\n } finally {\n abort();\n queue.length = 0;\n resolver = undefined;\n return;\n }\n }\n\n /**\n * Pushes one or more values to all listeners.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @param value - The first value to push\n * @param values - Additional values to push\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n * stream.listen(value => console.log('Received:', value));\n *\n * stream.push(1); // Received: 1\n * stream.push(2, 3, 4); // Received: 2, Received: 3, Received: 4\n * ```\n */\n push(value: VALUE, ...values: VALUE[]): void {\n values.unshift(value);\n for (const value of values) {\n for (const listener of this._listeners) {\n listener(value);\n }\n }\n }\n\n /**\n * Adds a listener to the stream.\n *\n * @param listener - Function to call when values are pushed\n * @param signal - Optional AbortSignal for cleanup\n * @returns Cleanup function to remove the listener\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<string>();\n *\n * // Basic listener\n * const cleanup = stream.listen(value => console.log(value));\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * stream.listen(value => console.log(value), controller.signal);\n * controller.abort(); // Removes listener\n *\n * // Manual cleanup\n * cleanup();\n * ```\n */\n listen(listener: (value: VALUE) => void, signal?: AbortSignal | Stream<any>): () => void {\n const self = this;\n let signalAbort: Function | undefined;\n\n if (signal instanceof AbortSignal) {\n if (signal?.aborted) return () => {};\n signal?.addEventListener(\"abort\", abort);\n signalAbort = () => signal?.removeEventListener(\"abort\", abort);\n } else {\n signalAbort = signal?.listen(abort);\n }\n\n self._listeners.add(listener);\n\n self._listenerAdded?.push();\n\n if (self._generatorFn && self._listeners.size === 1) {\n self._generator = self._generatorFn();\n (async () => {\n for await (const value of self._generator!) {\n self.push(value);\n }\n })();\n }\n return abort;\n function abort(): void {\n self._listeners.delete(listener);\n self._listenerRemoved?.push();\n if (self._listeners.size === 0) {\n self._generator?.return();\n self._generator = undefined;\n }\n signalAbort?.();\n }\n }\n\n /**\n * Promise-like interface that resolves with the next value.\n *\n * @param onfulfilled - Optional transformation function\n * @returns Promise that resolves with the first value\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n *\n * setTimeout(()=>{\n * stream.push(5);\n * })\n * // Wait for first value\n * const firstValue = await stream; // Resolves promises with 5\n *\n *\n * ```\n */\n then(onfulfilled?: ((value: VALUE) => VALUE | PromiseLike<VALUE>) | null): Promise<VALUE> {\n return new Promise<VALUE>((resolve) => {\n const abort = this.listen((value) => {\n resolve(value);\n abort();\n });\n }).then(onfulfilled);\n }\n\n /**\n * Applies a transformer function to this stream, enabling functional composition.\n *\n * @param transformer - Function that takes a stream and returns any output type\n * @returns The result of the transformer function\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const numbers = new Stream<number>();\n *\n * // Chain transformers\n * const result = numbers\n * .pipe(filter({}, (_, n) => [n > 0, {}]))\n * .pipe(map({}, (_, n) => [n * 2, {}]))\n * .pipe(toState(0));\n *\n * // Custom transformer\n * const throttle = <T>(ms: number) => (stream: Stream<T>) =>\n * new Stream<T>(async function* () {\n * let lastEmit = 0;\n * for await (const value of stream) {\n * const now = Date.now();\n * if (now - lastEmit >= ms) {\n * yield value;\n * lastEmit = now;\n * }\n * }\n * });\n *\n * // Transform to any type\n * const stringResult = numbers.pipe(throttle(1000));\n * const stateResult = numbers.pipe(toState(0));\n * ```\n */\n pipe<OUTPUT extends Stream<any>>(transformer: (stream: this) => OUTPUT): OUTPUT {\n return transformer(this);\n }\n}\n",
6
- "import { Stream } from \"../stream.ts\";\n\n/**\n * Adaptive filter transformer that maintains state and can terminate streams.\n *\n * @template VALUE - The type of values flowing through the stream\n * @template STATE - The type of the internal state object\n *\n * @param initialState - Initial state object for the transformer\n * @param predicate - Function that determines if a value should pass through\n * - Returns `[boolean, newState]` to continue with updated state\n * - Returns `void` or `undefined` to terminate the stream\n * - Can be async for complex filtering logic\n *\n * @returns A transformer function that can be used with `.pipe()`\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * // Simple filtering\n * stream.pipe(filter({}, (_, value) => [value > 0, {}]))\n *\n * @example\n * // Async filtering\n * stream.pipe(\n * filter({}, async (_, value) => {\n * const valid = await validate(value);\n * return [valid, {}];\n * })\n * )\n *\n\n *\n */\nexport function filter<VALUE, STATE extends Record<string, unknown> = {}>(\n initialState: STATE,\n predicate: (state: STATE, value: VALUE) => [boolean, STATE] | void | Promise<[boolean, STATE] | void>\n): (stream: Stream<VALUE>) => Stream<VALUE> {\n return (stream: Stream<VALUE>): Stream<VALUE> =>\n new Stream<VALUE>(async function* () {\n let currentState = initialState;\n\n for await (const value of stream) {\n const result = await predicate(currentState, value);\n if (!result) return;\n const [emit, state] = result;\n currentState = state;\n if (emit) {\n yield value;\n }\n }\n });\n}\n",
7
- "import { State } from \"../reactive/state.ts\";\nimport { Stream } from \"../stream.ts\";\n\n/**\n * Adaptive map transformer that transforms values while maintaining state.\n *\n * @template VALUE - The type of input values\n * @template STATE - The type of the internal state object\n * @template MAPPED - The type of output values after transformation\n *\n * @param initialState - Initial state object for the transformer\n * @param predicate - Function that transforms values and updates state\n * - Must return `[transformedValue, newState]`\n * - Can be async for complex transformations\n * - Preserves order even with async operations\n *\n * @returns A transformer function that can be used with `.pipe()`\n * \n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * // Simple transformation\n * stream.pipe(map({}, (_, value) => [value * 2, {}]))\n *\n * @example\n * // Async transformation\n * stream.pipe(\n * map({}, async (_, value) => {\n * const result = await process(value);\n * return [result, {}];\n * })\n * )\n *\n\n *\n */\nexport function map<VALUE, STATE extends Record<string, unknown>, MAPPED>(\n initialState: STATE,\n predicate: (state: STATE, value: VALUE) => [MAPPED, STATE] | Promise<[MAPPED, STATE]>\n): (stream: Stream<VALUE>) => Stream<MAPPED> {\n return (stream: Stream<VALUE>): Stream<MAPPED> =>\n new Stream<MAPPED>(async function* () {\n let currentState = initialState;\n for await (const value of stream) {\n const [mapped, state] = await predicate(currentState, value);\n currentState = state;\n yield mapped;\n }\n });\n}\n",
8
- "import { Stream } from \"../stream.ts\";\n\ntype ValueOf<STREAM> = STREAM extends Stream<infer VALUE> ? VALUE : never;\n\n/**\n * Merge multiple streams into a single stream with temporal ordering.\n * \n * @template VALUE - The type of values from the source stream\n * @template STREAMS - Tuple type of additional streams to merge\n * \n * @param streams - Additional streams to merge with the source stream\n * \n * @returns A transformer that merges all streams into one with union types\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * // Basic merge with type safety\n * const numbers = new Stream<number>();\n * const strings = new Stream<string>();\n * const merged = numbers.pipe(merge(strings));\n * // Type: Stream<number | string>\n * \n * @example\n * // Multiple streams\n * const stream1 = new Stream<number>();\n * const stream2 = new Stream<string>();\n * const stream3 = new Stream<boolean>();\n * \n * const combined = stream1.pipe(merge(stream2, stream3));\n * // Type: Stream<number | string | boolean>\n * \n\n */\nexport function merge<VALUE, STREAMS extends [Stream<any>, ...Stream<any>[]]>(\n ...streams: STREAMS\n): (stream: Stream<VALUE>) => Stream<VALUE | ValueOf<STREAMS[number]>> {\n return (stream: Stream<VALUE>): Stream<VALUE | ValueOf<STREAMS[number]>> =>\n new Stream<VALUE | ValueOf<STREAMS[number]>>(async function* () {\n const allStreams = [stream, ...streams];\n const queue: (VALUE | ValueOf<STREAMS[number]>)[] = [];\n let resolver: Function | undefined;\n\n const cleanups = allStreams.map((s) =>\n s.listen((value) => {\n queue.push(value);\n resolver?.();\n })\n );\n\n try {\n while (true) {\n if (queue.length) {\n yield queue.shift()!;\n } else {\n await new Promise((resolve) => (resolver = resolve));\n }\n }\n } finally {\n cleanups.forEach((cleanup) => cleanup());\n }\n });\n}\n",
9
- "import { Stream } from \"../stream.ts\";\nimport { map } from \"./map.ts\";\n\n/**\n * Flatten arrays in a stream, converting 1 array event into N individual events.\n *\n * @template VALUE - The type of values in the stream (should be arrays)\n * @template DEPTH - The depth of flattening (0 = one level, 1 = two levels, etc.)\n *\n * @param depth - How many levels deep to flatten (default: 0 = one level)\n *\n * @returns A transformer that flattens array values into individual events\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * // Basic flattening - 1 array → N events\n * const arrayStream = new Stream<number[]>();\n * const individualNumbers = arrayStream.pipe(flat());\n *\n * arrayStream.push([1, 2, 3]); // Emits: 1, 2, 3 as separate events\n *\n * @example\n * // Deep flattening\n * const deepArrays = new Stream<number[][]>();\n * const flattened = deepArrays.pipe(flat(1)); // Flatten 2 levels\n *\n * deepArrays.push([[1, 2], [3, 4]]);\n * // Emits: 1, 2, 3, 4 as separate events\n *\n */\nexport function flat<VALUE, DEPTH extends number = 0>(\n depth: DEPTH = 0 as DEPTH\n): (stream: Stream<VALUE>) => Stream<FlatArray<VALUE, DEPTH>> {\n return (stream: Stream<VALUE>): Stream<FlatArray<VALUE, DEPTH>> => {\n return new Stream<FlatArray<VALUE, DEPTH>>(async function* () {\n for await (const value of stream) {\n if (Array.isArray(value)) {\n const values = value.flat(depth);\n for (let i = 0; i < values.length; i++) {\n yield values[i]!;\n }\n } else {\n yield value as FlatArray<VALUE, DEPTH>;\n }\n }\n });\n };\n}\n",
5
+ "/**\n * A reactive streaming library that provides async-first data structures with built-in event streams.\n *\n * @template VALUE - The type of values that flow through the stream\n *\n * @example\n * ```typescript\n * // Basic usage\n * const stream = new Stream<number>();\n * stream.listen(value => console.log(value));\n * stream.push(1, 2, 3);\n *\n * // With async generator\n * const timerStream = new Stream(async function* () {\n * let count = 0;\n * while (count < 5) {\n * yield count++;\n * await new Promise(resolve => setTimeout(resolve, 1000));\n * }\n * });\n *\n * // Async iteration\n * for await (const value of stream) {\n * console.log(value);\n * if (value === 10) break;\n * }\n * ```\n *\n * @example\n * // 📦 COPY-PASTE TRANSFORMERS LIBRARY - Essential transformers for immediate use\n *\n * // FILTERING TRANSFORMERS\n *\n * const take = <T>(n: number) =>\n * filter<T, { count: number }>({ count: 0 }, (state, value) => {\n * if (state.count >= n) return;\n * return [true, { count: state.count + 1 }];\n * });\n *\n * const distinct = <T>() =>\n * filter<T, { seen: Set<T> }>({ seen: new Set() }, (state, value) => {\n * if (state.seen.has(value)) return [false, state];\n * state.seen.add(value);\n * return [true, state];\n * });\n *\n * const tap = <T>(fn: (value: T) => void | Promise<void>) =>\n * filter<T, {}>({}, async (_, value) => {\n * await fn(value);\n * return [true, {}];\n * });\n *\n * // MAPPING TRANSFORMERS\n *\n * const withIndex = <T>() =>\n * map<T, { index: number }, { value: T; index: number }>(\n * { index: 0 },\n * (state, value) => [\n * { value, index: state.index },\n * { index: state.index + 1 }\n * ]\n * );\n *\n * const delay = <T>(ms: number) =>\n * map<T, {}, T>({}, async (_, value) => {\n * await new Promise(resolve => setTimeout(resolve, ms));\n * return [value, {}];\n * });\n *\n * const scan = <T, U>(fn: (acc: U, value: T) => U, initial: U) =>\n * map<T, { acc: U }, U>({ acc: initial }, (state, value) => {\n * const newAcc = fn(state.acc, value);\n * return [newAcc, { acc: newAcc }];\n * });\n *\n * // STATE CONVERTER\n * const toState = <T>(initialValue: T) => (stream: Stream<T>) => {\n * return new State(initialValue, stream);\n * };\n *\n * // Usage: stream.pipe(simpleFilter(x => x > 0)).pipe(take(5)).pipe(toState(0));\n */\nexport class Stream<VALUE = unknown> implements AsyncIterable<VALUE> {\n protected _listeners: Set<(value: VALUE) => void> = new Set<(value: VALUE) => void>();\n protected _generatorFn: Stream.FunctionGenerator<VALUE> | undefined;\n protected _generator: AsyncGenerator<VALUE, void> | undefined;\n protected _listenerAdded: Stream<void> | undefined;\n protected _listenerRemoved: Stream<void> | undefined;\n\n /**\n * Creates a new Stream instance.\n *\n * @param generatorFn - Optional async generator function to produce values you can use it for creating stream with custom transformation\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * // Empty stream\n * const stream = new Stream<string>();\n *\n * // Stream with generator\n * const countdown = new Stream(async function* () {\n * for (let i = 5; i > 0; i--) {\n * yield i;\n * await new Promise(resolve => setTimeout(resolve, 1000));\n * }\n * });\n *\n * // Stream with custom transformer\n * function filter<VALUE>(source:Stream<VALUE>,predicate:(value:VALUE) => boolean):Stream<VALUE>{\n * return new Stream<VALUE>(async function* () {\n * for await (const value of source) {\n * if (predicate(value)) yield value ;\n * }\n * });\n * }\n * const source = new Stream<number>();\n * const even = filter(source,v=> v % 2 === 0)\n * even.listen(console.log);\n * source.push(1, 2, 3, 4); // 2,4\n * ```\n */\n constructor();\n constructor(stream: Stream.FunctionGenerator<VALUE> | Stream<VALUE>);\n constructor(stream?: Stream.FunctionGenerator<VALUE> | Stream<VALUE>) {\n this._generatorFn = stream instanceof Stream ? () => stream[Symbol.asyncIterator]() : stream;\n }\n\n /**\n * Returns true if the stream has active listeners.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n * console.log(stream.hasListeners); // false\n *\n * const cleanup = stream.listen(value => console.log(value));\n * console.log(stream.hasListeners); // true\n *\n * cleanup();\n * console.log(stream.hasListeners); // false\n * ```\n */\n get hasListeners(): boolean {\n return this._listeners.size > 0;\n }\n\n /**\n * Stream that emits when a listener is added.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n * stream.listenerAdded.listen(() => console.log('Listener added'));\n *\n * stream.listen(value => console.log(value)); // Triggers 'Listener added'\n * ```\n */\n get listenerAdded(): Stream<void> {\n if (!this._listenerAdded) this._listenerAdded = new Stream<void>();\n return this._listenerAdded;\n }\n\n /**\n * Stream that emits when a listener is removed.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n * stream.listenerRemoved.listen(() => console.log('Listener removed'));\n *\n * const cleanup = stream.listen(value => console.log(value));\n * cleanup(); // Triggers 'Listener removed'\n * ```\n */\n get listenerRemoved(): Stream<void> {\n if (!this._listenerRemoved) this._listenerRemoved = new Stream<void>();\n return this._listenerRemoved;\n }\n async *[Symbol.asyncIterator](): AsyncGenerator<VALUE, void> {\n const queue: VALUE[] = [];\n let resolver: Function | undefined;\n\n const abort = this.listen((value) => {\n queue.push(value);\n resolver?.();\n });\n\n try {\n while (true) {\n if (queue.length) yield queue.shift()!;\n else await new Promise<void>((resolve) => (resolver = resolve));\n }\n } finally {\n abort();\n queue.length = 0;\n resolver = undefined;\n return;\n }\n }\n\n /**\n * Pushes one or more values to all listeners.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @param value - The first value to push\n * @param values - Additional values to push\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n * stream.listen(value => console.log('Received:', value));\n *\n * stream.push(1); // Received: 1\n * stream.push(2, 3, 4); // Received: 2, Received: 3, Received: 4\n * ```\n */\n push(value: VALUE, ...values: VALUE[]): void {\n values.unshift(value);\n for (const value of values) {\n for (const listener of this._listeners) {\n listener(value);\n }\n }\n }\n\n /**\n * Adds a listener to the stream.\n *\n * @param listener - Function to call when values are pushed\n * @param signal - Optional AbortSignal for cleanup\n * @returns Cleanup function to remove the listener\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<string>();\n *\n * // Basic listener\n * const cleanup = stream.listen(value => console.log(value));\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * stream.listen(value => console.log(value), controller.signal);\n * controller.abort(); // Removes listener\n *\n * // Manual cleanup\n * cleanup();\n * ```\n */\n listen(listener: (value: VALUE) => void, signal?: AbortSignal | Stream<any>): () => void {\n const self = this;\n let signalAbort: Function | undefined;\n\n if (signal instanceof AbortSignal) {\n if (signal?.aborted) return () => {};\n signal?.addEventListener(\"abort\", abort);\n signalAbort = () => signal?.removeEventListener(\"abort\", abort);\n } else {\n signalAbort = signal?.listen(abort);\n }\n\n self._listeners.add(listener);\n\n self._listenerAdded?.push();\n\n if (self._generatorFn && self._listeners.size === 1) {\n self._generator = self._generatorFn();\n (async () => {\n for await (const value of self._generator!) {\n self.push(value);\n }\n })();\n }\n return abort;\n function abort(): void {\n self._listeners.delete(listener);\n self._listenerRemoved?.push();\n if (self._listeners.size === 0) {\n self._generator?.return();\n self._generator = undefined;\n }\n signalAbort?.();\n }\n }\n\n /**\n * Promise-like interface that resolves with the next value.\n *\n * @param onfulfilled - Optional transformation function\n * @returns Promise that resolves with the first value\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const stream = new Stream<number>();\n *\n * setTimeout(()=>{\n * stream.push(5);\n * })\n * // Wait for first value\n * const firstValue = await stream; // Resolves promises with 5\n *\n *\n * ```\n */\n then(onfulfilled?: ((value: VALUE) => VALUE | PromiseLike<VALUE>) | null): Promise<VALUE> {\n return new Promise<VALUE>((resolve) => {\n const abort = this.listen((value) => {\n resolve(value);\n abort();\n });\n }).then(onfulfilled);\n }\n\n /**\n * Applies a transformer function to this stream, enabling functional composition.\n *\n * @param transformer - Function that takes a stream and returns any output type\n * @returns The result of the transformer function\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const numbers = new Stream<number>();\n *\n * // Chain transformers\n * const result = numbers\n * .pipe(filter({}, (_, n) => [n > 0, {}]))\n * .pipe(map({}, (_, n) => [n * 2, {}]))\n * .pipe(toState(0));\n *\n * // Custom transformer\n * const throttle = <T>(ms: number) => (stream: Stream<T>) =>\n * new Stream<T>(async function* () {\n * let lastEmit = 0;\n * for await (const value of stream) {\n * const now = Date.now();\n * if (now - lastEmit >= ms) {\n * yield value;\n * lastEmit = now;\n * }\n * }\n * });\n *\n * // Transform to any type\n * const stringResult = numbers.pipe(throttle(1000));\n * const stateResult = numbers.pipe(toState(0));\n * ```\n */\n pipe<OUTPUT extends Stream<any>>(transformer: (stream: this) => OUTPUT): OUTPUT {\n return transformer(this);\n }\n}\n\nexport namespace Stream {\n export type ValueOf<STREAM> = STREAM extends Stream<infer VALUE> ? VALUE : never;\n export type FunctionGenerator<VALUE> = () => AsyncGenerator<VALUE, void>;\n}\n",
6
+ "import { Stream } from \"../stream.ts\";\n\n/**\n * Adaptive filter transformer that maintains state and can terminate streams.\n * Supports multiple concurrency strategies for async predicates.\n *\n * @template VALUE - The type of values flowing through the stream\n * @template STATE - The type of the internal state object\n * @template FILTERED - The type of filtered values (for type guards)\n *\n * @param initialStateOrPredicate - Initial state object or predicate function\n * @param statefulPredicateOrOptions - Stateful predicate function or options for simple predicates\n *\n * @returns A transformer function that can be used with `.pipe()`\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * // Simple synchronous filtering\n * stream.pipe(filter((value) => value > 0))\n *\n * @example\n * // Type guard filtering (synchronous only)\n * stream.pipe(filter((value): value is number => typeof value === \"number\"))\n *\n * @example\n * // Async filtering with sequential strategy (default)\n * stream.pipe(\n * filter(async (value) => {\n * const valid = await validateAsync(value);\n * return valid;\n * })\n * )\n *\n * @example\n * // Async filtering with concurrent-unordered strategy\n * stream.pipe(\n * filter(async (value) => {\n * const result = await expensiveCheck(value);\n * return result;\n * }, { strategy: \"concurrent-unordered\" })\n * )\n *\n * @example\n * // Async filtering with concurrent-ordered strategy\n * stream.pipe(\n * filter(async (value) => {\n * const result = await apiValidation(value);\n * return result;\n * }, { strategy: \"concurrent-ordered\" })\n * )\n *\n * @example\n * // Stateful filtering (always sequential)\n * stream.pipe(\n * filter({ count: 0 }, (state, value) => {\n * if (state.count >= 10) return; // Terminate after 10 items\n * return [value > 0, { count: state.count + 1 }];\n * })\n * )\n *\n * @example\n * // Stateful filtering with complex state\n * stream.pipe(\n * filter({ seen: new Set() }, (state, value) => {\n * if (state.seen.has(value)) return [false, state]; // Duplicate\n * state.seen.add(value);\n * return [true, state]; // First occurrence\n * })\n * )\n *\n * @example\n * // Stream termination\n * stream.pipe(\n * filter(async (value) => {\n * if (value === \"STOP\") return; // Terminates stream\n * return value.length > 3;\n * })\n * )\n */\nexport const filter: filter.Filter = <\n VALUE,\n STATE extends Record<string, unknown> = {},\n FILTERED extends VALUE = VALUE\n>(\n initialStateOrPredicate: STATE | filter.Predicate<VALUE> | filter.GuardPredicate<VALUE, FILTERED>,\n statefulPredicateOrOptions?:\n | filter.StatefulPredicate<VALUE, STATE>\n | filter.StatefulGuardPredicate<VALUE, STATE, FILTERED>\n | filter.Options\n): ((stream: Stream<VALUE>) => Stream<FILTERED>) => {\n return (stream: Stream<VALUE>): Stream<FILTERED> => {\n if (!statefulPredicateOrOptions || typeof statefulPredicateOrOptions === \"object\") {\n const { strategy = \"sequential\" } = statefulPredicateOrOptions ?? {};\n\n const predicate = initialStateOrPredicate as filter.Predicate<VALUE>;\n\n if (strategy === \"sequential\") {\n return new Stream<FILTERED>(async function* () {\n for await (const value of stream) {\n const result = await predicate(value);\n if (result) yield value as FILTERED;\n if (result === undefined) return;\n }\n });\n }\n\n if (strategy === \"concurrent-unordered\") {\n return new Stream<FILTERED>(async function* () {\n const ABORT = Symbol.for(\"__abort\");\n\n let queue = new Array<FILTERED | typeof ABORT>();\n let resolver: Function | undefined;\n\n const abort = stream.listen(async (value) => {\n const result = await predicate(value);\n if (result !== false) {\n result === undefined ? queue.push(ABORT) : queue.push(value as FILTERED);\n resolver?.();\n resolver = undefined;\n }\n });\n\n try {\n while (true) {\n if (queue.length) {\n const value = queue.shift()!;\n if (value === ABORT) break;\n yield value;\n } else {\n await new Promise<void>((r) => (resolver = r));\n }\n }\n } finally {\n queue.length = 0;\n abort();\n resolver = undefined;\n }\n });\n }\n\n if (strategy === \"concurrent-ordered\") {\n return new Stream<FILTERED>(async function* () {\n let queue = new Array<{ resultPromise: boolean | void | Promise<boolean | void>; value: VALUE }>();\n let resolver: Function | undefined;\n\n const abort = stream.listen((value) => {\n const pormise = predicate(value);\n queue.push({ resultPromise: pormise, value });\n (async () => {\n await pormise;\n resolver?.();\n resolver = undefined;\n })();\n });\n\n try {\n while (true) {\n if (queue.length) {\n const { resultPromise, value } = queue.shift()!;\n const result = await resultPromise;\n if (result) yield value as FILTERED;\n if (result === undefined) break;\n } else {\n await new Promise<void>((r) => (resolver = r));\n }\n }\n } finally {\n queue.length = 0;\n abort();\n resolver = undefined;\n }\n });\n }\n }\n\n const predicate = statefulPredicateOrOptions as filter.StatefulGuardPredicate<VALUE, STATE>;\n\n return new Stream<FILTERED>(async function* () {\n let currentState = initialStateOrPredicate as STATE;\n for await (const value of stream) {\n const result = await predicate(currentState, value);\n if (!result) return;\n const [emit, state] = result;\n currentState = state;\n if (emit) {\n yield value as FILTERED;\n }\n }\n });\n };\n};\n\nexport namespace filter {\n export type Options = { strategy: \"sequential\" | \"concurrent-unordered\" | \"concurrent-ordered\" };\n export type Predicate<VALUE = unknown> = (value: VALUE) => boolean | void | Promise<boolean | void>;\n export type GuardPredicate<VALUE = unknown, FILTERED extends VALUE = VALUE> = (value: VALUE) => value is FILTERED;\n export type StatefulPredicate<VALUE = unknown, STATE extends Record<string, unknown> = {}> = (\n state: STATE,\n value: VALUE\n ) => [boolean, STATE] | void | Promise<[boolean, STATE] | void>;\n export type StatefulGuardPredicate<\n VALUE = unknown,\n STATE extends Record<string, unknown> = {},\n FILTERED extends VALUE = VALUE\n > = (state: STATE, value: VALUE) => [boolean, STATE, FILTERED] | void | Promise<[boolean, STATE, FILTERED] | void>;\n export interface Filter {\n <VALUE, FILTERED extends VALUE = VALUE>(predicate: GuardPredicate<VALUE, FILTERED>): (\n stream: Stream<VALUE>\n ) => Stream<FILTERED>;\n\n <VALUE>(predicate: Predicate<VALUE>, options?: Options): (stream: Stream<VALUE>) => Stream<VALUE>;\n\n <VALUE, STATE extends Record<string, unknown> = {}>(\n initialState: STATE,\n predicate: StatefulPredicate<VALUE, STATE>\n ): (stream: Stream<VALUE>) => Stream<VALUE>;\n\n <VALUE, STATE extends Record<string, unknown> = {}, FILTERED extends VALUE = VALUE>(\n initialState: STATE,\n predicate: StatefulGuardPredicate<VALUE, STATE, FILTERED>\n ): (stream: Stream<VALUE>) => Stream<FILTERED>;\n }\n}\n",
7
+ "import { Stream } from \"../stream.ts\";\n\n/**\n * Adaptive map transformer that transforms values while maintaining state.\n * Supports multiple concurrency strategies for async mappers.\n *\n * @template VALUE - The type of input values\n * @template STATE - The type of the internal state object\n * @template MAPPED - The type of output values after transformation\n *\n * @param initialStateOrMapper - Initial state object or mapper function\n * @param statefulMapperOrOptions - Stateful mapper function or options for simple mappers\n *\n * @returns A transformer function that can be used with `.pipe()`\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * // Simple synchronous transformation\n * stream.pipe(map((value) => value * 2))\n *\n * @example\n * // Type transformation\n * stream.pipe(map((value: number) => value.toString()))\n *\n * @example\n * // Async transformation with sequential strategy (default)\n * stream.pipe(\n * map(async (value) => {\n * const result = await processAsync(value);\n * return result;\n * })\n * )\n *\n * @example\n * // Async transformation with concurrent-unordered strategy\n * stream.pipe(\n * map(async (value) => {\n * const enriched = await enrichWithAPI(value);\n * return enriched;\n * }, { strategy: \"concurrent-unordered\" })\n * )\n *\n * @example\n * // Async transformation with concurrent-ordered strategy\n * stream.pipe(\n * map(async (value) => {\n * const processed = await heavyProcessing(value);\n * return processed;\n * }, { strategy: \"concurrent-ordered\" })\n * )\n *\n * @example\n * // Stateful transformation (always sequential)\n * stream.pipe(\n * map({ sum: 0 }, (state, value) => {\n * const newSum = state.sum + value;\n * return [{ value, runningSum: newSum }, { sum: newSum }];\n * })\n * )\n *\n * @example\n * // Complex stateful transformation\n * stream.pipe(\n * map({ count: 0, items: [] }, (state, value) => {\n * const newItems = [...state.items, value];\n * const newCount = state.count + 1;\n * return [\n * {\n * item: value,\n * index: newCount,\n * total: newItems.length,\n * history: newItems\n * },\n * { count: newCount, items: newItems }\n * ];\n * })\n * )\n *\n * @example\n * // Async stateful transformation\n * stream.pipe(\n * map({ cache: new Map() }, async (state, value) => {\n * const cached = state.cache.get(value);\n * if (cached) return [cached, state];\n *\n * const processed = await expensiveOperation(value);\n * const newCache = new Map(state.cache);\n * newCache.set(value, processed);\n *\n * return [processed, { cache: newCache }];\n * })\n * )\n */\nexport const map: map.Map = <VALUE, STATE extends Record<string, unknown>, MAPPED>(\n initialStateOrMapper: STATE | map.Mapper<VALUE, MAPPED>,\n statefulMapper?: map.StatefulMapper<VALUE, STATE, MAPPED> | map.Options\n): ((stream: Stream<VALUE>) => Stream<MAPPED>) => {\n return (stream: Stream<VALUE>): Stream<MAPPED> => {\n if (!statefulMapper || typeof statefulMapper === \"object\") {\n const { strategy = \"sequential\" } = statefulMapper ?? {};\n const mapper = initialStateOrMapper as map.Mapper<VALUE, MAPPED>;\n\n if (strategy === \"sequential\") {\n return new Stream<MAPPED>(async function* () {\n for await (const value of stream) {\n yield await mapper(value);\n }\n });\n }\n if (strategy === \"concurrent-unordered\") {\n return new Stream<MAPPED>(async function* () {\n let queue = new Array<MAPPED>();\n let resolver: Function | undefined;\n\n const abort = stream.listen(async (value) => {\n queue.push(await mapper(value));\n resolver?.();\n resolver = undefined;\n });\n\n try {\n while (true) {\n if (queue.length) {\n yield queue.shift()!;\n } else {\n await new Promise<void>((r) => (resolver = r));\n }\n }\n } finally {\n queue.length = 0;\n abort();\n resolver = undefined;\n }\n });\n }\n\n if (strategy === \"concurrent-ordered\") {\n return new Stream<MAPPED>(async function* () {\n let queue = new Array<MAPPED | Promise<MAPPED>>();\n let resolver: Function | undefined;\n\n const abort = stream.listen((value) => {\n const promise = mapper(value);\n\n queue.push(promise);\n\n (async () => {\n await promise;\n resolver?.();\n resolver = undefined;\n })();\n });\n\n try {\n while (true) {\n if (queue.length) {\n yield await queue.shift()!;\n } else {\n await new Promise<void>((r) => (resolver = r));\n }\n }\n } finally {\n queue.length = 0;\n abort();\n resolver = undefined;\n }\n });\n }\n }\n\n const mapper = statefulMapper as map.StatefulMapper<VALUE, STATE, MAPPED>;\n\n return new Stream<MAPPED>(async function* () {\n let currentState = initialStateOrMapper as STATE;\n for await (const value of stream) {\n const [mapped, state] = await mapper(currentState, value);\n currentState = state;\n yield mapped;\n }\n });\n };\n};\n\nexport namespace map {\n export type Options = { strategy: \"sequential\" | \"concurrent-unordered\" | \"concurrent-ordered\" };\n export type Mapper<VALUE = unknown, MAPPED = VALUE> = (value: VALUE) => MAPPED | Promise<MAPPED>;\n export type StatefulMapper<VALUE = unknown, STATE extends Record<string, unknown> = {}, MAPPED = VALUE> = (\n state: STATE,\n value: VALUE\n ) => [MAPPED, STATE] | Promise<[MAPPED, STATE]>;\n\n export interface Map {\n <VALUE, MAPPED>(mapper: Mapper<VALUE, MAPPED>, options?: Options): (stream: Stream<VALUE>) => Stream<MAPPED>;\n <VALUE, STATE extends Record<string, unknown> = {}, MAPPED = VALUE>(\n initialState: STATE,\n mapper: StatefulMapper<VALUE, STATE, MAPPED>\n ): (stream: Stream<VALUE>) => Stream<MAPPED>;\n }\n}\n",
8
+ "import { Stream } from \"../stream.ts\";\n\n/**\n * Merge multiple streams into a single stream with temporal ordering.\n * \n * @template VALUE - The type of values from the source stream\n * @template STREAMS - Tuple type of additional streams to merge\n * \n * @param streams - Additional streams to merge with the source stream\n * \n * @returns A transformer that merges all streams into one with union types\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * // Basic merge with type safety\n * const numbers = new Stream<number>();\n * const strings = new Stream<string>();\n * const merged = numbers.pipe(merge(strings));\n * // Type: Stream<number | string>\n * \n * @example\n * // Multiple streams\n * const stream1 = new Stream<number>();\n * const stream2 = new Stream<string>();\n * const stream3 = new Stream<boolean>();\n * \n * const combined = stream1.pipe(merge(stream2, stream3));\n * // Type: Stream<number | string | boolean>\n * \n\n */\nexport function merge<VALUE, STREAMS extends [Stream<any>, ...Stream<any>[]]>(\n ...streams: STREAMS\n): (stream: Stream<VALUE>) => Stream<VALUE | Stream.ValueOf<STREAMS[number]>> {\n return (stream: Stream<VALUE>): Stream<VALUE | Stream.ValueOf<STREAMS[number]>> =>\n new Stream<VALUE | Stream.ValueOf<STREAMS[number]>>(async function* () {\n const allStreams = [stream, ...streams];\n const queue: (VALUE | Stream.ValueOf<STREAMS[number]>)[] = [];\n let resolver: Function | undefined;\n\n const cleanups = allStreams.map((s) =>\n s.listen((value) => {\n queue.push(value);\n resolver?.();\n })\n );\n\n try {\n while (true) {\n if (queue.length) {\n yield queue.shift()!;\n } else {\n await new Promise((resolve) => (resolver = resolve));\n }\n }\n } finally {\n cleanups.forEach((cleanup) => cleanup());\n }\n });\n}\n",
9
+ "import { Stream } from \"../stream.ts\";\n\n/**\n * Flatten arrays in a stream, converting 1 array event into N individual events.\n *\n * @template VALUE - The type of values in the stream (should be arrays)\n * @template DEPTH - The depth of flattening (0 = one level, 1 = two levels, etc.)\n *\n * @param depth - How many levels deep to flatten (default: 0 = one level)\n *\n * @returns A transformer that flattens array values into individual events\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * // Basic flattening - 1 array → N events\n * const arrayStream = new Stream<number[]>();\n * const individualNumbers = arrayStream.pipe(flat());\n *\n * arrayStream.push([1, 2, 3]); // Emits: 1, 2, 3 as separate events\n *\n * @example\n * // Deep flattening\n * const deepArrays = new Stream<number[][]>();\n * const flattened = deepArrays.pipe(flat(1)); // Flatten 2 levels\n *\n * deepArrays.push([[1, 2], [3, 4]]);\n * // Emits: 1, 2, 3, 4 as separate events\n *\n */\nexport function flat<VALUE, DEPTH extends number = 0>(\n depth: DEPTH = 0 as DEPTH\n): (stream: Stream<VALUE>) => Stream<FlatArray<VALUE, DEPTH>> {\n return (stream: Stream<VALUE>): Stream<FlatArray<VALUE, DEPTH>> => {\n return new Stream<FlatArray<VALUE, DEPTH>>(async function* () {\n for await (const value of stream) {\n if (Array.isArray(value)) {\n const values = value.flat(depth);\n for (let i = 0; i < values.length; i++) {\n yield values[i]!;\n }\n } else {\n yield value as FlatArray<VALUE, DEPTH>;\n }\n }\n });\n };\n}\n",
10
10
  "import { Stream } from \"../stream.ts\";\n\n/**\n * A reactive List that provides array-like functionality with stream-based mutation events.\n * Emits events when items are inserted, deleted, or the list is cleared.\n * Supports negative indexing with modulo wrapping.\n * @template VALUE - The type of values stored in the list\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const todos = new List<string>();\n *\n * // Listen to insertions\n * todos.insert.listen(([index, item]) => {\n * console.log(`Added \"${item}\" at index ${index}`);\n * });\n *\n * // Listen to deletions\n * todos.delete.listen(([index, item]) => {\n * console.log(`Removed \"${item}\" from index ${index}`);\n * });\n *\n * todos.insert(0, \"Buy milk\"); //Added \"Buy milk\" at index 0\n * todos.insert(1, \"Walk dog\"); //Added \"Walk dog\" at index 1\n * todos.insert(-1, \"kechma haja\"); //Added \"kechma haja\" at index 2\n * todos[0] = \"Buy organic milk\"; // Added \"Buy organic milk\" at index 0\n * ```\n */\nexport class List<VALUE> implements Iterable<VALUE> {\n private _items: VALUE[] = [];\n private _insertStream?: Stream<[number, VALUE]>;\n private _deleteStream?: Stream<[number, VALUE]>;\n private _clearStream?: Stream<void>;\n\n [index: number]: VALUE | undefined;\n\n /**\n * Inserts a value at the specified index and emits the insertion event.\n * Negative indices are handled specially for insertion positioning.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const list = new List([1, 2, 3]);\n * list.insert.listen(([index, value]) => console.log(`Inserted ${value} at ${index}`));\n *\n * list.insert(1, 99); // Inserted 99 at 1 → [1, 99, 2, 3]\n * list.insert(-1, 88); // Insert at end → [1, 99, 2, 3, 88]\n * ```\n */\n declare insert: ((index: number, value: VALUE) => this) & Stream<[number, VALUE]>;\n\n /**\n * Deletes a value at the specified index and emits the deletion event.\n * Returns the deleted value or undefined if index is invalid.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const list = new List(['a', 'b', 'c']);\n * list.delete.listen(([index, value]) => console.log(`Deleted ${value} from ${index}`));\n *\n * const deleted = list.delete(1); // Deleted b from 1\n * console.log(deleted); // 'b'\n * ```\n */\n declare delete: ((index: number) => VALUE | undefined) & Stream<[number, VALUE]>;\n\n /**\n * Clears all items from the list and emits the clear event.\n * Only emits if the list was not already empty.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const list = new List([1, 2, 3]);\n * list.clear.listen(() => console.log('List cleared'));\n *\n * list.clear(); // List cleared\n * list.clear(); // No emission (already empty)\n * ```\n */\n declare clear: (() => void) & Stream<void>;\n\n /**\n * Creates a new reactive List.\n *\n * @param items - Optional iterable of initial items\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * // Empty list\n * const list = new List<number>();\n *\n * // With initial items\n * const todos = new List(['Buy milk', 'Walk dog']);\n *\n * // Listen to changes\n * todos.insert.listen(([index, item]) => updateUI(index, item));\n * todos.delete.listen(([index, item]) => removeFromUI(index));\n *\n * // Index access with modulo wrapping\n * console.log(todos[0]); // 'Buy milk'\n * console.log(todos[-1]); // 'Walk dog' (last item)\n * ```\n */\n constructor(items?: Iterable<VALUE>) {\n if (items) this._items = [...items];\n\n const self = this;\n\n function normalizeIndex(index: number, length: number): number {\n if (length === 0) return 0;\n return index < 0 ? ((index % length) + length) % length : index % length;\n }\n\n this.insert = new Proxy(\n (index: number, value: VALUE): this => {\n const actualIndex =\n index < 0 ? Math.max(0, self._items.length + index + 1) : Math.min(index, self._items.length);\n self._items.splice(actualIndex, 0, value);\n self._insertStream?.push([actualIndex, value]);\n return proxy;\n },\n {\n get(target, prop) {\n if (prop in target) return (target as any)[prop];\n if (!self._insertStream) self._insertStream = new Stream();\n return (self._insertStream as any)[prop];\n },\n }\n ) as any;\n this.delete = new Proxy(\n (index: number): VALUE | undefined => {\n if (index < 0 || index >= self._items.length) return undefined;\n const value = self._items.splice(index, 1)[0]!;\n self._deleteStream?.push([index, value]);\n return value;\n },\n {\n get(target, prop) {\n if (prop in target) return (target as any)[prop];\n if (!self._deleteStream) self._deleteStream = new Stream();\n return (self._deleteStream as any)[prop];\n },\n }\n ) as any;\n\n this.clear = new Proxy(\n (): void => {\n if (self._items.length > 0) {\n self._items.length = 0;\n self._clearStream?.push();\n }\n },\n {\n get(target, prop) {\n if (prop in target) return (target as any)[prop];\n if (!self._clearStream) self._clearStream = new Stream();\n return (self._clearStream as any)[prop];\n },\n }\n ) as any;\n\n const proxy = new Proxy(this, {\n get(target, prop) {\n if (typeof prop === \"string\" && /^-?\\d+$/.test(prop)) {\n const index = parseInt(prop);\n if (target._items.length === 0) return undefined;\n const actualIndex = normalizeIndex(index, target._items.length);\n return target._items[actualIndex];\n }\n return (target as any)[prop];\n },\n\n set(target, prop, value) {\n if (typeof prop === \"string\" && /^-?\\d+$/.test(prop)) {\n const index = parseInt(prop);\n\n if (target._items.length === 0) {\n // Empty array: any index mutation adds first element at index 0\n target._items.push(value);\n target._insertStream?.push([0, value]);\n return true;\n }\n\n const actualIndex = normalizeIndex(index, target._items.length);\n const oldValue = target._items[actualIndex];\n\n if (oldValue !== value) {\n target._items[actualIndex] = value;\n target._insertStream?.push([actualIndex, value]);\n }\n return true;\n }\n (target as any)[prop] = value;\n return true;\n },\n });\n\n return proxy;\n }\n\n /**\n * Gets the value at the specified index without modulo wrapping.\n *\n * @param index - The index to access\n * @returns The value at the index or undefined\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const list = new List([10, 20, 30]);\n * console.log(list.get(1)); // 20\n * console.log(list.get(5)); // undefined\n * ```\n */\n get(index: number): VALUE | undefined {\n return this._items[index];\n }\n\n /**\n * Gets the current length of the list.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const list = new List([1, 2, 3]);\n * console.log(list.length); // 3\n *\n * list.insert(0, 0);\n * console.log(list.length); // 4\n * ```\n */\n get length(): number {\n return this._items.length;\n }\n /**\n * Returns an iterator for the list values.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const list = new List([1, 2, 3]);\n * for (const value of list.values()) {\n * console.log(value); // 1, 2, 3\n * }\n * ```\n */\n values(): IterableIterator<VALUE> {\n return this._items[Symbol.iterator]();\n }\n /**\n * Makes the list iterable.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const list = new List(['a', 'b', 'c']);\n * for (const item of list) {\n * console.log(item); // 'a', 'b', 'c'\n * }\n *\n * const array = [...list]; // ['a', 'b', 'c']\n * ```\n */\n [Symbol.iterator](): IterableIterator<VALUE> {\n return this._items[Symbol.iterator]();\n }\n}\n",
11
11
  "import { Stream } from \"../stream.ts\";\n\n/**\n * A reactive Map that extends the native Map with stream-based mutation events.\n * Emits events when entries are set, deleted, or the map is cleared.\n *\n * @template KEY - The type of keys in the map\n * @template VALUE - The type of values in the map\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const cache = new Map<string, any>();\n *\n * // Listen to cache updates\n * cache.set.listen(([key, value]) => {\n * console.log(`Cache updated: ${key} = ${value}`);\n * });\n *\n * // Listen to cache evictions\n * cache.delete.listen(([key, value]) => {\n * console.log(`Cache evicted: ${key}`);\n * });\n *\n * cache.set('user:123', { name: 'John' });\n * cache.delete('user:123');\n * ```\n */\nexport class Map<KEY, VALUE> extends globalThis.Map<KEY, VALUE> {\n protected _setStream?: Stream<[KEY, VALUE]>;\n protected _deleteStream?: Stream<[KEY, VALUE]>;\n protected _clearStream?: Stream<void>;\n\n /**\n * Sets a key-value pair in the map and emits the entry to listeners.\n * Only emits if the value actually changes (not same key-value pair).\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const config = new Map<string, string>();\n * config.set.listen(([key, value]) => console.log(`Set: ${key}=${value}`));\n *\n * config.set('theme', 'dark'); // Set: theme=dark\n * config.set('theme', 'dark'); // No emission (same value)\n * config.set('theme', 'light'); // Set: theme=light\n * ```\n */\n declare set: ((key: KEY, value: VALUE) => this) & Stream<[KEY, VALUE]>;\n\n /**\n * Deletes a key from the map and emits the deleted entry to listeners.\n * Only emits if the key was actually deleted (existed in map).\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const users = new Map([['alice', { age: 30 }], ['bob', { age: 25 }]]);\n * users.delete.listen(([key, value]) => console.log(`Removed: ${key}`));\n *\n * users.delete('alice'); // Removed: alice\n * users.delete('charlie'); // No emission (didn't exist)\n * ```\n */\n declare delete: ((key: KEY) => boolean) & Stream<[KEY, VALUE]>;\n\n /**\n * Clears all entries from the map and emits to listeners.\n * Only emits if the map was not already empty.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const store = new Map([['a', 1], ['b', 2]]);\n * store.clear.listen(() => console.log('Store cleared'));\n *\n * store.clear(); // Store cleared\n * store.clear(); // No emission (already empty)\n * ```\n */\n declare clear: (() => void) & Stream<void>;\n\n /**\n * Creates a new reactive Map.\n *\n * @param entries - Optional iterable of initial key-value pairs\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * // Empty map\n * const cache = new Map<string, any>();\n *\n * // With initial entries\n * const config = new Map([\n * ['theme', 'dark'],\n * ['lang', 'en']\n * ]);\n *\n * // Listen to changes\n * config.set.listen(([key, value]) => saveConfig(key, value));\n * config.delete.listen(([key]) => removeConfig(key));\n * ```\n */\n constructor(entries?: Iterable<[KEY, VALUE]>) {\n super(entries);\n\n const self = this;\n\n this.set = new Proxy(\n (key: KEY, value: VALUE): this => {\n if (globalThis.Map.prototype.has.call(self, key) && globalThis.Map.prototype.get.call(self, key) === value)\n return self;\n globalThis.Map.prototype.set.call(self, key, value);\n self._setStream?.push([key, value]);\n return self;\n },\n {\n get(target, prop) {\n if (prop in target) return (target as any)[prop];\n if (!self._setStream) self._setStream = new Stream();\n return (self._setStream as any)[prop];\n },\n }\n ) as any;\n\n this.delete = new Proxy(\n (key: KEY): boolean => {\n if (!globalThis.Map.prototype.has.call(self, key)) return false;\n const value = globalThis.Map.prototype.get.call(self, key);\n globalThis.Map.prototype.delete.call(self, key);\n self._deleteStream?.push([key, value]);\n return true;\n },\n {\n get(target, prop) {\n if (prop in target) return (target as any)[prop];\n if (!self._deleteStream) self._deleteStream = new Stream();\n return (self._deleteStream as any)[prop];\n },\n }\n ) as any;\n\n this.clear = new Proxy(\n (): void => {\n if (self.size > 0) {\n globalThis.Map.prototype.clear.call(self);\n self._clearStream?.push();\n }\n },\n {\n get(target, prop) {\n if (prop in target) return (target as any)[prop];\n if (!self._clearStream) self._clearStream = new Stream();\n return (self._clearStream as any)[prop];\n },\n }\n ) as any;\n }\n}\n",
12
12
  "import { Stream } from \"../stream.ts\";\n\n/**\n * A reactive Set that extends the native Set with stream-based mutation events.\n * Emits events when items are added, deleted, or the set is cleared.\n *\n * @template VALUE - The type of values stored in the set\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const activeUsers = new Set<string>();\n *\n * // Listen to additions\n * activeUsers.add.listen(userId => {\n * console.log(`User ${userId} came online`);\n * });\n *\n * // Listen to deletions\n * activeUsers.delete.listen(userId => {\n * console.log(`User ${userId} went offline`);\n * });\n *\n * activeUsers.add('alice'); // User alice came online\n * activeUsers.delete('alice'); // User alice went offline\n * ```\n */\nexport class Set<VALUE> extends globalThis.Set<VALUE> {\n protected _addStream?: Stream<VALUE>;\n protected _deleteStream?: Stream<VALUE>;\n protected _clearStream?: Stream<void>;\n\n /**\n * Adds a value to the set and emits the value to listeners.\n * Only emits if the value is actually added (not a duplicate).\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const tags = new Set<string>();\n * tags.add.listen(tag => console.log('Added:', tag));\n *\n * tags.add('javascript'); // Added: javascript\n * tags.add('javascript'); // No emission (duplicate)\n * ```\n */\n declare add: ((value: VALUE) => this) & Stream<VALUE>;\n\n /**\n * Deletes a value from the set and emits the value to listeners.\n * Only emits if the value was actually deleted (existed in set).\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const items = new Set(['a', 'b', 'c']);\n * items.delete.listen(item => console.log('Removed:', item));\n *\n * items.delete('b'); // Removed: b\n * items.delete('x'); // No emission (didn't exist)\n * ```\n */\n declare delete: ((value: VALUE) => boolean) & Stream<VALUE>;\n\n /**\n * Clears all values from the set and emits to listeners.\n * Only emits if the set was not already empty.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const cache = new Set([1, 2, 3]);\n * cache.clear.listen(() => console.log('Cache cleared'));\n *\n * cache.clear(); // Cache cleared\n * cache.clear(); // No emission (already empty)\n * ```\n */\n declare clear: (() => void) & Stream<void>;\n\n /**\n * Creates a new reactive Set.\n *\n * @param values - Optional iterable of initial values\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * // Empty set\n * const tags = new Set<string>();\n *\n * // With initial values\n * const colors = new Set(['red', 'green', 'blue']);\n *\n * // Listen to changes\n * colors.add.listen(color => updateUI(color));\n * colors.delete.listen(color => removeFromUI(color));\n * ```\n */\n constructor(values?: Iterable<VALUE>) {\n super(values);\n\n const self = this;\n\n this.add = new Proxy(\n (value: VALUE): this => {\n if (globalThis.Set.prototype.has.call(self, value)) return self;\n globalThis.Set.prototype.add.call(self, value);\n self._addStream?.push(value);\n return self;\n },\n {\n get(target, prop) {\n if (prop in target) return (target as any)[prop];\n if (!self._addStream) self._addStream = new Stream<VALUE>();\n return (self._addStream as any)[prop];\n },\n }\n ) as any;\n\n this.delete = new Proxy(\n (value: VALUE): boolean => {\n if (!globalThis.Set.prototype.has.call(self, value)) return false;\n globalThis.Set.prototype.delete.call(self, value);\n self._deleteStream?.push(value);\n return true;\n },\n {\n get(target, prop) {\n if (prop in target) return (target as any)[prop];\n if (!self._deleteStream) self._deleteStream = new Stream<VALUE>();\n return (self._deleteStream as any)[prop];\n },\n }\n ) as any;\n\n this.clear = new Proxy(\n (): void => {\n if (self.size > 0) {\n globalThis.Set.prototype.clear.call(self);\n self._clearStream?.push();\n }\n },\n {\n get(target, prop) {\n if (prop in target) return (target as any)[prop];\n if (!self._clearStream) self._clearStream = new Stream<void>();\n return (self._clearStream as any)[prop];\n },\n }\n ) as any;\n }\n}\n",
13
- "import { FunctionGenerator, Stream } from \"../stream.ts\";\n\n/**\n * A reactive state container that extends Stream to provide stateful value management.\n *\n * @template VALUE - The type of the state value\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * // Basic state\n * const counter = new State(0);\n * counter.listen(value => console.log('Counter:', value));\n * counter.value = 5; // Counter: 5\n *\n * // State from stream\n * const source = new Stream<number>();\n * const state = new State(0, source);\n * state.listen(value => console.log('State:', value));\n * source.push(1, 2, 3); // State: 1, State: 2, State: 3\n *\n * // State from transformed stream\n * const filtered = source.pipe(filter({}, (_, v) => [v > 0, {}]));\n * const derivedState = new State(-1, filtered);\n * ```\n */\nexport class State<VALUE> extends Stream<VALUE> {\n protected _value: VALUE;\n constructor(initialValue: VALUE);\n constructor(initialValue: VALUE, stream: FunctionGenerator<VALUE> | Stream<VALUE>);\n /**\n * Creates a new State with an initial value.\n *\n * @param initialValue - The initial state value\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const count = new State(0);\n * const theme = new State<'light' | 'dark'>('light');\n * const user = new State<User | null>(null);\n * ```\n */\n constructor(initialValue: VALUE, stream?: FunctionGenerator<VALUE> | Stream<VALUE>) {\n stream ? super(stream) : super();\n this._value = initialValue;\n }\n /**\n * Updates the state with one or more values sequentially.\n * Each value triggers listeners and updates the current state.\n *\n * @param values - Values to set as state\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const state = new State(0);\n * state.listen(v => console.log(v));\n *\n * state.push(1, 2, 3); // Logs: 1, 2, 3\n * console.log(state.value); // 3\n * ```\n */\n override push(...values: VALUE[]): void {\n for (const value of values) {\n this.value = value;\n }\n }\n /**\n * Gets the current state value.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const state = new State('hello');\n * console.log(state.value); // 'hello'\n * ```\n */\n get value(): VALUE {\n return this._value;\n }\n /**\n * Sets the current state value and notifies all listeners.\n *\n * @param value - The new state value\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const state = new State(0);\n * state.listen(v => console.log('New value:', v));\n *\n * state.value = 42; // New value: 42\n * state.value = 100; // New value: 100\n * ```\n */\n set value(value: VALUE) {\n this._value = value;\n super.push(value);\n }\n}\n"
13
+ "import { Stream } from \"../stream.ts\";\n\n/**\n * A reactive state container that extends Stream to provide stateful value management.\n *\n * @template VALUE - The type of the state value\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * // Basic state\n * const counter = new State(0);\n * counter.listen(value => console.log('Counter:', value));\n * counter.value = 5; // Counter: 5\n *\n * // State from stream\n * const source = new Stream<number>();\n * const state = new State(0, source);\n * state.listen(value => console.log('State:', value));\n * source.push(1, 2, 3); // State: 1, State: 2, State: 3\n *\n * // State from transformed stream\n * const filtered = source.pipe(filter({}, (_, v) => [v > 0, {}]));\n * const derivedState = new State(-1, filtered);\n * ```\n */\nexport class State<VALUE = unknown> extends Stream<VALUE> {\n protected _value: VALUE;\n constructor(initialValue: VALUE);\n constructor(initialValue: VALUE, stream: Stream.FunctionGenerator<VALUE> | Stream<VALUE>);\n /**\n * Creates a new State with an initial value.\n *\n * @param initialValue - The initial state value\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const count = new State(0);\n * const theme = new State<'light' | 'dark'>('light');\n * const user = new State<User | null>(null);\n * ```\n */\n constructor(initialValue: VALUE, stream?: Stream.FunctionGenerator<VALUE> | Stream<VALUE>) {\n super(stream!);\n this._value = initialValue;\n }\n /**\n * Updates the state with one or more values sequentially.\n * Each value triggers listeners and updates the current state.\n *\n * @param values - Values to set as state\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const state = new State(0);\n * state.listen(v => console.log(v));\n *\n * state.push(1, 2, 3); // Logs: 1, 2, 3\n * console.log(state.value); // 3\n * ```\n */\n override push(...values: VALUE[]): void {\n for (const value of values) {\n this.value = value;\n }\n }\n /**\n * Gets the current state value.\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const state = new State('hello');\n * console.log(state.value); // 'hello'\n * ```\n */\n get value(): VALUE {\n return this._value;\n }\n /**\n * Sets the current state value and notifies all listeners.\n *\n * @param value - The new state value\n *\n * @see {@link Stream} - Complete copy-paste transformers library\n *\n * @example\n * ```typescript\n * const state = new State(0);\n * state.listen(v => console.log('New value:', v));\n *\n * state.value = 42; // New value: 42\n * state.value = 100; // New value: 100\n * ```\n */\n set value(value: VALUE) {\n this._value = value;\n super.push(value);\n }\n}\n"
14
14
  ],
15
- "mappings": "AA8FO,MAAM,CAAwD,CACzD,WAA0C,IAAI,IAC9C,aACA,WACA,eACA,iBAsCV,WAAW,CAAC,EAAmD,CAC7D,KAAK,aAAe,aAAkB,EAAS,IAAM,EAAO,OAAO,eAAe,EAAI,KAoBpF,aAAY,EAAY,CAC1B,OAAO,KAAK,WAAW,KAAO,KAgB5B,cAAa,EAAiB,CAChC,IAAK,KAAK,eAAgB,KAAK,eAAiB,IAAI,EACpD,OAAO,KAAK,kBAiBV,gBAAe,EAAiB,CAClC,IAAK,KAAK,iBAAkB,KAAK,iBAAmB,IAAI,EACxD,OAAO,KAAK,wBAEN,OAAO,cAAc,EAAgC,CAC3D,IAAM,EAAiB,CAAC,EACpB,EAEE,EAAQ,KAAK,OAAO,CAAC,IAAU,CACnC,EAAM,KAAK,CAAK,EAChB,IAAW,EACZ,EAED,GAAI,CACF,MAAO,GACL,GAAI,EAAM,OAAQ,MAAM,EAAM,MAAM,EAC/B,WAAM,IAAI,QAAc,CAAC,IAAa,EAAW,CAAQ,SAEhE,CACA,EAAM,EACN,EAAM,OAAS,EACf,EAAW,OACX,QAqBJ,IAAI,CAAC,KAAiB,EAAuB,CAC3C,EAAO,QAAQ,CAAK,EACpB,QAAW,KAAS,EAClB,QAAW,KAAY,KAAK,WA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,CAAK,EAEpB",
16
+ "debugId": "632A5D3113A6752264756E2164756E21",
17
17
  "names": []
18
18
  }
@@ -1,4 +1,4 @@
1
- import { FunctionGenerator, Stream } from "../stream.ts";
1
+ import { Stream } from "../stream.ts";
2
2
  /**
3
3
  * A reactive state container that extends Stream to provide stateful value management.
4
4
  *
@@ -24,10 +24,10 @@ import { FunctionGenerator, Stream } from "../stream.ts";
24
24
  * const derivedState = new State(-1, filtered);
25
25
  * ```
26
26
  */
27
- export declare class State<VALUE> extends Stream<VALUE> {
27
+ export declare class State<VALUE = unknown> extends Stream<VALUE> {
28
28
  protected _value: VALUE;
29
29
  constructor(initialValue: VALUE);
30
- constructor(initialValue: VALUE, stream: FunctionGenerator<VALUE> | Stream<VALUE>);
30
+ constructor(initialValue: VALUE, stream: Stream.FunctionGenerator<VALUE> | Stream<VALUE>);
31
31
  /**
32
32
  * Updates the state with one or more values sequentially.
33
33
  * Each value triggers listeners and updates the current state.
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/reactive/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,KAAK,CAAC,KAAK,CAAE,SAAQ,MAAM,CAAC,KAAK,CAAC;IAC7C,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC;gBACZ,YAAY,EAAE,KAAK;gBACnB,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IAmBjF;;;;;;;;;;;;;;;;OAgBG;IACM,IAAI,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;IAKvC;;;;;;;;;;OAUG;IACH,IAAI,KAAK,IAAI,KAAK,CAEjB;IACD;;;;;;;;;;;;;;;OAeG;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,EAGrB;CACF"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/reactive/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,KAAK,CAAC,KAAK,GAAG,OAAO,CAAE,SAAQ,MAAM,CAAC,KAAK,CAAC;IACvD,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC;gBACZ,YAAY,EAAE,KAAK;gBACnB,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IAmBxF;;;;;;;;;;;;;;;;OAgBG;IACM,IAAI,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;IAKvC;;;;;;;;;;OAUG;IACH,IAAI,KAAK,IAAI,KAAK,CAEjB;IACD;;;;;;;;;;;;;;;OAeG;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,EAGrB;CACF"}
package/dist/stream.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- export type ValueOf<STREAM> = STREAM extends Stream<infer VALUE> ? VALUE : never;
2
- export type FunctionGenerator<VALUE> = () => AsyncGenerator<VALUE, void>;
3
1
  /**
4
2
  * A reactive streaming library that provides async-first data structures with built-in event streams.
5
3
  *
@@ -32,11 +30,6 @@ export type FunctionGenerator<VALUE> = () => AsyncGenerator<VALUE, void>;
32
30
  * // 📦 COPY-PASTE TRANSFORMERS LIBRARY - Essential transformers for immediate use
33
31
  *
34
32
  * // FILTERING TRANSFORMERS
35
- * const simpleFilter = <T>(predicate: (value: T) => boolean | Promise<boolean>) =>
36
- * filter<T, {}>({}, async (_, value) => {
37
- * const shouldPass = await predicate(value);
38
- * return [shouldPass, {}];
39
- * });
40
33
  *
41
34
  * const take = <T>(n: number) =>
42
35
  * filter<T, { count: number }>({ count: 0 }, (state, value) => {
@@ -58,11 +51,6 @@ export type FunctionGenerator<VALUE> = () => AsyncGenerator<VALUE, void>;
58
51
  * });
59
52
  *
60
53
  * // MAPPING TRANSFORMERS
61
- * const simpleMap = <T, U>(fn: (value: T) => U | Promise<U>) =>
62
- * map<T, {}, U>({}, async (_, value) => {
63
- * const result = await fn(value);
64
- * return [result, {}];
65
- * });
66
54
  *
67
55
  * const withIndex = <T>() =>
68
56
  * map<T, { index: number }, { value: T; index: number }>(
@@ -94,7 +82,7 @@ export type FunctionGenerator<VALUE> = () => AsyncGenerator<VALUE, void>;
94
82
  */
95
83
  export declare class Stream<VALUE = unknown> implements AsyncIterable<VALUE> {
96
84
  protected _listeners: Set<(value: VALUE) => void>;
97
- protected _generatorFn: FunctionGenerator<VALUE> | undefined;
85
+ protected _generatorFn: Stream.FunctionGenerator<VALUE> | undefined;
98
86
  protected _generator: AsyncGenerator<VALUE, void> | undefined;
99
87
  protected _listenerAdded: Stream<void> | undefined;
100
88
  protected _listenerRemoved: Stream<void> | undefined;
@@ -133,7 +121,7 @@ export declare class Stream<VALUE = unknown> implements AsyncIterable<VALUE> {
133
121
  * ```
134
122
  */
135
123
  constructor();
136
- constructor(stream: FunctionGenerator<VALUE> | Stream<VALUE>);
124
+ constructor(stream: Stream.FunctionGenerator<VALUE> | Stream<VALUE>);
137
125
  /**
138
126
  * Returns true if the stream has active listeners.
139
127
  *
@@ -286,4 +274,8 @@ export declare class Stream<VALUE = unknown> implements AsyncIterable<VALUE> {
286
274
  */
287
275
  pipe<OUTPUT extends Stream<any>>(transformer: (stream: this) => OUTPUT): OUTPUT;
288
276
  }
277
+ export declare namespace Stream {
278
+ type ValueOf<STREAM> = STREAM extends Stream<infer VALUE> ? VALUE : never;
279
+ type FunctionGenerator<VALUE> = () => AsyncGenerator<VALUE, void>;
280
+ }
289
281
  //# sourceMappingURL=stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"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AGhF;AAED,yBAAiB,MAAM,CAAC;IACtB,KAAY,OAAO,CAAC,MAAM,IAAI,MAAM,SAAS,MAAM,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC;IACjF,KAAY,iBAAiB,CAAC,KAAK,IAAI,MAAM,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;CAC1E"}
@@ -1,35 +1,96 @@
1
1
  import { Stream } from "../stream.ts";
2
2
  /**
3
3
  * Adaptive filter transformer that maintains state and can terminate streams.
4
+ * Supports multiple concurrency strategies for async predicates.
4
5
  *
5
6
  * @template VALUE - The type of values flowing through the stream
6
7
  * @template STATE - The type of the internal state object
8
+ * @template FILTERED - The type of filtered values (for type guards)
7
9
  *
8
- * @param initialState - Initial state object for the transformer
9
- * @param predicate - Function that determines if a value should pass through
10
- * - Returns `[boolean, newState]` to continue with updated state
11
- * - Returns `void` or `undefined` to terminate the stream
12
- * - Can be async for complex filtering logic
10
+ * @param initialStateOrPredicate - Initial state object or predicate function
11
+ * @param statefulPredicateOrOptions - Stateful predicate function or options for simple predicates
13
12
  *
14
13
  * @returns A transformer function that can be used with `.pipe()`
15
14
  *
16
15
  * @see {@link Stream} - Complete copy-paste transformers library
17
16
  *
18
17
  * @example
19
- * // Simple filtering
20
- * stream.pipe(filter({}, (_, value) => [value > 0, {}]))
18
+ * // Simple synchronous filtering
19
+ * stream.pipe(filter((value) => value > 0))
21
20
  *
22
21
  * @example
23
- * // Async filtering
22
+ * // Type guard filtering (synchronous only)
23
+ * stream.pipe(filter((value): value is number => typeof value === "number"))
24
+ *
25
+ * @example
26
+ * // Async filtering with sequential strategy (default)
24
27
  * stream.pipe(
25
- * filter({}, async (_, value) => {
26
- * const valid = await validate(value);
27
- * return [valid, {}];
28
+ * filter(async (value) => {
29
+ * const valid = await validateAsync(value);
30
+ * return valid;
28
31
  * })
29
32
  * )
30
33
  *
31
-
34
+ * @example
35
+ * // Async filtering with concurrent-unordered strategy
36
+ * stream.pipe(
37
+ * filter(async (value) => {
38
+ * const result = await expensiveCheck(value);
39
+ * return result;
40
+ * }, { strategy: "concurrent-unordered" })
41
+ * )
42
+ *
43
+ * @example
44
+ * // Async filtering with concurrent-ordered strategy
45
+ * stream.pipe(
46
+ * filter(async (value) => {
47
+ * const result = await apiValidation(value);
48
+ * return result;
49
+ * }, { strategy: "concurrent-ordered" })
50
+ * )
32
51
  *
52
+ * @example
53
+ * // Stateful filtering (always sequential)
54
+ * stream.pipe(
55
+ * filter({ count: 0 }, (state, value) => {
56
+ * if (state.count >= 10) return; // Terminate after 10 items
57
+ * return [value > 0, { count: state.count + 1 }];
58
+ * })
59
+ * )
60
+ *
61
+ * @example
62
+ * // Stateful filtering with complex state
63
+ * stream.pipe(
64
+ * filter({ seen: new Set() }, (state, value) => {
65
+ * if (state.seen.has(value)) return [false, state]; // Duplicate
66
+ * state.seen.add(value);
67
+ * return [true, state]; // First occurrence
68
+ * })
69
+ * )
70
+ *
71
+ * @example
72
+ * // Stream termination
73
+ * stream.pipe(
74
+ * filter(async (value) => {
75
+ * if (value === "STOP") return; // Terminates stream
76
+ * return value.length > 3;
77
+ * })
78
+ * )
33
79
  */
34
- export declare function filter<VALUE, STATE extends Record<string, unknown> = {}>(initialState: STATE, predicate: (state: STATE, value: VALUE) => [boolean, STATE] | void | Promise<[boolean, STATE] | void>): (stream: Stream<VALUE>) => Stream<VALUE>;
80
+ export declare const filter: filter.Filter;
81
+ export declare namespace filter {
82
+ type Options = {
83
+ strategy: "sequential" | "concurrent-unordered" | "concurrent-ordered";
84
+ };
85
+ type Predicate<VALUE = unknown> = (value: VALUE) => boolean | void | Promise<boolean | void>;
86
+ type GuardPredicate<VALUE = unknown, FILTERED extends VALUE = VALUE> = (value: VALUE) => value is FILTERED;
87
+ type StatefulPredicate<VALUE = unknown, STATE extends Record<string, unknown> = {}> = (state: STATE, value: VALUE) => [boolean, STATE] | void | Promise<[boolean, STATE] | void>;
88
+ type StatefulGuardPredicate<VALUE = unknown, STATE extends Record<string, unknown> = {}, FILTERED extends VALUE = VALUE> = (state: STATE, value: VALUE) => [boolean, STATE, FILTERED] | void | Promise<[boolean, STATE, FILTERED] | void>;
89
+ interface Filter {
90
+ <VALUE, FILTERED extends VALUE = VALUE>(predicate: GuardPredicate<VALUE, FILTERED>): (stream: Stream<VALUE>) => Stream<FILTERED>;
91
+ <VALUE>(predicate: Predicate<VALUE>, options?: Options): (stream: Stream<VALUE>) => Stream<VALUE>;
92
+ <VALUE, STATE extends Record<string, unknown> = {}>(initialState: STATE, predicate: StatefulPredicate<VALUE, STATE>): (stream: Stream<VALUE>) => Stream<VALUE>;
93
+ <VALUE, STATE extends Record<string, unknown> = {}, FILTERED extends VALUE = VALUE>(initialState: STATE, predicate: StatefulGuardPredicate<VALUE, STATE, FILTERED>): (stream: Stream<VALUE>) => Stream<FILTERED>;
94
+ }
95
+ }
35
96
  //# sourceMappingURL=filter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/transformers/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,EACtE,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,GACpG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,CAe1C"}
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/transformers/filter.ts"],"names":[],"mappings":"AAAA,OAAO,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AkB,GACxB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAe5D"}
1
+ {"version":3,"file":"flat.d.ts","sourceRoot":"","sources":["../../src/transformers/flat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,KAAK,SAAS,MAAM,GAAG,CAAC,EAClD,KAAK,GAAE,KAAkB,GACxB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAe5D"}
@@ -1,36 +1,106 @@
1
1
  import { Stream } from "../stream.ts";
2
2
  /**
3
3
  * Adaptive map transformer that transforms values while maintaining state.
4
+ * Supports multiple concurrency strategies for async mappers.
4
5
  *
5
6
  * @template VALUE - The type of input values
6
7
  * @template STATE - The type of the internal state object
7
8
  * @template MAPPED - The type of output values after transformation
8
9
  *
9
- * @param initialState - Initial state object for the transformer
10
- * @param predicate - Function that transforms values and updates state
11
- * - Must return `[transformedValue, newState]`
12
- * - Can be async for complex transformations
13
- * - Preserves order even with async operations
10
+ * @param initialStateOrMapper - Initial state object or mapper function
11
+ * @param statefulMapperOrOptions - Stateful mapper function or options for simple mappers
14
12
  *
15
13
  * @returns A transformer function that can be used with `.pipe()`
16
14
  *
17
15
  * @see {@link Stream} - Complete copy-paste transformers library
18
16
  *
19
17
  * @example
20
- * // Simple transformation
21
- * stream.pipe(map({}, (_, value) => [value * 2, {}]))
18
+ * // Simple synchronous transformation
19
+ * stream.pipe(map((value) => value * 2))
22
20
  *
23
21
  * @example
24
- * // Async transformation
22
+ * // Type transformation
23
+ * stream.pipe(map((value: number) => value.toString()))
24
+ *
25
+ * @example
26
+ * // Async transformation with sequential strategy (default)
25
27
  * stream.pipe(
26
- * map({}, async (_, value) => {
27
- * const result = await process(value);
28
- * return [result, {}];
28
+ * map(async (value) => {
29
+ * const result = await processAsync(value);
30
+ * return result;
29
31
  * })
30
32
  * )
31
33
  *
32
-
34
+ * @example
35
+ * // Async transformation with concurrent-unordered strategy
36
+ * stream.pipe(
37
+ * map(async (value) => {
38
+ * const enriched = await enrichWithAPI(value);
39
+ * return enriched;
40
+ * }, { strategy: "concurrent-unordered" })
41
+ * )
33
42
  *
43
+ * @example
44
+ * // Async transformation with concurrent-ordered strategy
45
+ * stream.pipe(
46
+ * map(async (value) => {
47
+ * const processed = await heavyProcessing(value);
48
+ * return processed;
49
+ * }, { strategy: "concurrent-ordered" })
50
+ * )
51
+ *
52
+ * @example
53
+ * // Stateful transformation (always sequential)
54
+ * stream.pipe(
55
+ * map({ sum: 0 }, (state, value) => {
56
+ * const newSum = state.sum + value;
57
+ * return [{ value, runningSum: newSum }, { sum: newSum }];
58
+ * })
59
+ * )
60
+ *
61
+ * @example
62
+ * // Complex stateful transformation
63
+ * stream.pipe(
64
+ * map({ count: 0, items: [] }, (state, value) => {
65
+ * const newItems = [...state.items, value];
66
+ * const newCount = state.count + 1;
67
+ * return [
68
+ * {
69
+ * item: value,
70
+ * index: newCount,
71
+ * total: newItems.length,
72
+ * history: newItems
73
+ * },
74
+ * { count: newCount, items: newItems }
75
+ * ];
76
+ * })
77
+ * )
78
+ *
79
+ * @example
80
+ * // Async stateful transformation
81
+ * stream.pipe(
82
+ * map({ cache: new Map() }, async (state, value) => {
83
+ * const cached = state.cache.get(value);
84
+ * if (cached) return [cached, state];
85
+ *
86
+ * const processed = await expensiveOperation(value);
87
+ * const newCache = new Map(state.cache);
88
+ * newCache.set(value, processed);
89
+ *
90
+ * return [processed, { cache: newCache }];
91
+ * })
92
+ * )
34
93
  */
35
- export declare function map<VALUE, STATE extends Record<string, unknown>, MAPPED>(initialState: STATE, predicate: (state: STATE, value: VALUE) => [MAPPED, STATE] | Promise<[MAPPED, STATE]>): (stream: Stream<VALUE>) => Stream<MAPPED>;
94
+ export declare const map: map.Map;
95
+ export declare namespace map {
96
+ type Options = {
97
+ strategy: "sequential" | "concurrent-unordered" | "concurrent-ordered";
98
+ };
99
+ type Mapper<VALUE = unknown, MAPPED = VALUE> = (value: VALUE) => MAPPED | Promise<MAPPED>;
100
+ type StatefulMapper<VALUE = unknown, STATE extends Record<string, unknown> = {}, MAPPED = VALUE> = (state: STATE, value: VALUE) => [MAPPED, STATE] | Promise<[MAPPED, STATE]>;
101
+ interface Map {
102
+ <VALUE, MAPPED>(mapper: Mapper<VALUE, MAPPED>, options?: Options): (stream: Stream<VALUE>) => Stream<MAPPED>;
103
+ <VALUE, STATE extends Record<string, unknown> = {}, MAPPED = VALUE>(initialState: STATE, mapper: StatefulMapper<VALUE, STATE, MAPPED>): (stream: Stream<VALUE>) => Stream<MAPPED>;
104
+ }
105
+ }
36
106
  //# sourceMappingURL=map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/transformers/map.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EACtE,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,GACpF,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAU3C"}
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/transformers/map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,M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AM,CAAC,MAAM,CAAC,CAAC;KAC9C;CACF"}
@@ -1,5 +1,4 @@
1
1
  import { Stream } from "../stream.ts";
2
- type ValueOf<STREAM> = STREAM extends Stream<infer VALUE> ? VALUE : never;
3
2
  /**
4
3
  * Merge multiple streams into a single stream with temporal ordering.
5
4
  *
@@ -30,6 +29,5 @@ type ValueOf<STREAM> = STREAM extends Stream<infer VALUE> ? VALUE : never;
30
29
  *
31
30
 
32
31
  */
33
- export declare function merge<VALUE, STREAMS extends [Stream<any>, ...Stream<any>[]]>(...streams: STREAMS): (stream: Stream<VALUE>) => Stream<VALUE | ValueOf<STREAMS[number]>>;
34
- export {};
32
+ export declare function merge<VALUE, STREAMS extends [Stream<any>, ...Stream<any>[]]>(...streams: STREAMS): (stream: Stream<VALUE>) => Stream<VALUE | Stream.ValueOf<STREAMS[number]>>;
35
33
  //# sourceMappingURL=merge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/transformers/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,KAAK,OAAO,CAAC,MAAM,IAAI,MAAM,SAAS,MAAM,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAC1E,GAAG,OAAO,EAAE,OAAO,GAClB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CA0BrE"}
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/transformers/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAC1E,GAAG,OAAO,EAAE,OAAO,GAClB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CA0B5E"}