uneventful 0.0.7 → 0.0.8
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/{call-or-wait-DHkBd_bM.mjs → call-or-wait-COAmx32w.mjs} +24 -92
- package/dist/call-or-wait-COAmx32w.mjs.map +1 -0
- package/dist/mod.d.ts +1 -1
- package/dist/mod.mjs +7 -4
- package/dist/mod.mjs.map +1 -1
- package/dist/signals.d.ts +47 -22
- package/dist/signals.mjs +143 -58
- package/dist/signals.mjs.map +1 -1
- package/dist/{sinks-kEzJo6Hc.d.ts → sinks-5TuxCRtX.d.ts} +26 -1
- package/dist/utils-P0JEpWXG.mjs +87 -0
- package/dist/utils-P0JEpWXG.mjs.map +1 -0
- package/dist/utils.d.ts +93 -1
- package/dist/utils.mjs +1 -17
- package/dist/utils.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/call-or-wait-DHkBd_bM.mjs.map +0 -1
package/dist/mod.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.mjs","sources":["../src/async.ts","../src/sources.ts","../src/sinks.ts","../src/operators.ts"],"sourcesContent":["import { Request, Yielding } from \"./types.ts\";\nimport { rejecter, resolve, resolver } from \"./results.ts\"\n\n/**\n * Convert a (possible) promise to something you can `yield *to()` in a job\n *\n * Much like `await valueOrPromiseLike` in an async function, using `yield\n * *to(valueOrPromiseLike)` in a {@link Job}'s generator function will return\n * the value or the result of the promise/promise-like object.\n *\n * @category Scheduling\n */\nexport function *to<T>(p: Promise<T> | PromiseLike<T> | T): Yielding<T> {\n return yield (res: Request<T>) => Promise.resolve(p).then(resolver(res), rejecter(res));\n}\n\n/**\n * Pause the job for the specified time in ms, e.g. `yield *sleep(1000)` to wait\n * one second.\n *\n * @category Scheduling\n */\nexport function *sleep(ms: number): Yielding<void> {\n try {\n var id: ReturnType<typeof setTimeout>;\n yield r => {\n id = setTimeout(() => { id = undefined; resolve(r, void 0); }, ms);\n }\n } finally {\n if (id) clearTimeout(id);\n }\n}\n","import { defer } from \"./defer.ts\";\nimport { type Stream, IsStream, backpressure, Sink, Connection, Backpressure, throttle, Inlet, Source } from \"./streams.ts\";\nimport { getJob, detached } from \"./tracking.ts\";\nimport { must, start } from \"./jobutils.ts\";\nimport { DisposeFn } from \"./types.ts\";\nimport { isCancel, isError, isUnhandled, markHandled, noop } from \"./results.ts\";\n\n/**\n * A function that emits events, with a .source they're emitted from\n *\n * Created using {@link emitter}.\n *\n * @category Types and Interfaces\n */\nexport interface Emitter<T> {\n /** Call the emitter to emit events on its .source */\n (val: T): void;\n /** An event source that receives the events */\n source: Source<T>;\n /** Close all current subscribers' connections */\n end: () => void;\n /** Close all current subscribers' connections with an error */\n throw: (e: any) => void;\n};\n\n/**\n * Create an event source and a function to emit events on it\n *\n * (Note: you must specify the event type (e.g. `emitter<number>()`), since\n * there's nothing else to infer it from.)\n *\n * @returns A function that emits events, with a .source property they're\n * emitted on.\n *\n * @category Stream Producers\n */\nexport function emitter<T>(): Emitter<T> {\n const emit = mockSource<T>();\n emit.source = share(emit.source);\n return emit;\n}\n\n/**\n * A stream that immediately closes\n *\n * @category Stream Producers\n */\nexport function empty(): Source<never> {\n return (_, conn) => (conn?.return(), IsStream);\n}\n\n/**\n * Convert an async iterable to an event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * each item output by the iterator, then end the stream. Pause/resume is\n * supported.\n *\n * @category Stream Producers\n */\nexport function fromAsyncIterable<T>(iterable: AsyncIterable<T>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const ready = backpressure(inlet);\n const iter = iterable[Symbol.asyncIterator]();\n if (iter.return) must(() => iter.return());\n return ready(next), IsStream;\n function next() {\n iter.next().then(({value, done}) => {\n if (done) conn.return(); else ready(() => {\n if (sink(value), ready()) next(); else ready(next);\n })\n }, e => conn.throw(e));\n }\n }\n}\n\n/**\n * Create an event source from an element, window, or other event target\n *\n * You can manually override the expected event type using a type parameter,\n * e.g. `fromDomEvent<CustomEvent>(someTarget, \"custom-event\")`.\n *\n * @param target an HTMLElement, Window, Document, or other EventTarget.\n * @param type the name of the event to add a listener for\n * @param options a boolean capture option, or an object of event listener\n * options\n * @returns a source that can be subscribed or piped, issuing events from the\n * target of the specified type.\n *\n * @category Stream Producers\n */\nexport function fromDomEvent<T extends HTMLElement, K extends keyof HTMLElementEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<HTMLElementEventMap[K]>;\nexport function fromDomEvent<T extends Window, K extends keyof WindowEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<WindowEventMap[K]>;\nexport function fromDomEvent<T extends Document, K extends keyof DocumentEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<DocumentEventMap[K]>;\nexport function fromDomEvent<T extends Event>(\n target: EventTarget, type: string, options?: boolean | AddEventListenerOptions\n): Source<T>\nexport function fromDomEvent<T extends EventTarget, K extends string>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<Event> {\n return (sink) => {\n function push(v: Event) { sink(v); }\n target.addEventListener(type, push, options);\n must(() => target.removeEventListener(type, push, options));\n return IsStream;\n }\n}\n\n/**\n * Convert an iterable to a synchronous event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * each item in the iterator, then close the connection. Pause/resume is\n * supported.\n *\n * @category Stream Producers\n */\nexport function fromIterable<T>(iterable: Iterable<T>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const ready = backpressure(inlet);\n const iter = iterable[Symbol.iterator]();\n if (iter.return) must(() => iter.return());\n return ready(loop), IsStream;\n function loop() {\n try {\n for(;;) {\n const {value, done} = iter.next();\n if (done) return conn.return();\n if (sink(value), !ready()) return ready(loop);\n }\n } catch (e) {\n conn.throw(e);\n }\n }\n }\n}\n\n/**\n * Convert a Promise to an event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * the result of the promise, then close the connection. (Unless the promise is\n * rejected, in which case the connection throws and closes each time the source\n * is subscribed.) Non-native promises and non-promise values are converted\n * using Promise.resolve().\n *\n * @category Stream Producers\n */\nexport function fromPromise<T>(promise: Promise<T>|PromiseLike<T>|T): Source<T> {\n return (sink, conn) => {\n const job = getJob();\n Promise.resolve(promise).then(\n v => void (job.result() || (sink(v), conn?.return())),\n e => void (job.result() || conn?.throw(e))\n )\n return IsStream;\n }\n}\n\n/**\n * Create an event source from an arbitrary subscribe/unsubscribe function\n *\n * The supplied \"subscribe\" function will be passed a 1-argument callback and\n * must return an unsubscribe function. The callback should be called with\n * events of the appropriate type, and the unsubscribe function will be called\n * when the connection is closed.\n *\n * (Note: it's okay if the act of subscribing causes an immediate callback, as\n * the subscribe function will be called in a separate microtask.)\n *\n * @category Stream Producers\n */\nexport function fromSubscribe<T>(subscribe: (cb: (val: T) => void) => DisposeFn): Source<T> {\n return (sink) => {\n const f = getJob().must(() => sink = noop);\n return defer(() => f.must(subscribe(v => { sink(v); }))), IsStream;\n }\n}\n\n/**\n * Create a source that emits a single given value\n *\n * @category Stream Producers\n */\nexport function fromValue<T>(val: T): Source<T> {\n return (sink, conn) => {\n must(() => { sink = noop; conn = undefined; })\n return defer(() => { sink(val); conn?.return(); }), IsStream;\n }\n}\n\n/**\n * Create an event source that issues a number every `ms` milliseconds (starting\n * with 0 after the first interval passes).\n *\n * @category Stream Producers\n */\nexport function interval(ms: number): Source<number> {\n return (sink) => {\n let idx = 0, id = setInterval(() => sink(idx++), ms);\n return must(() => clearInterval(id)), IsStream;\n }\n}\n\n/**\n * Create a dynamic source that is created each time it's subscribed\n *\n * @param factory A function returning a source of the desired type. It will be\n * called whenever the lazy() stream is subscribed, and its result subscribed to.\n *\n * @returns A stream of the same type as the factory function returns\n *\n * @category Stream Producers\n */\nexport function lazy<T>(factory: () => Stream<T>): Source<T> {\n return (sink, conn, inlet) => factory()(sink, conn, inlet)\n}\n\n/**\n * An {@link Emitter} with a ready() method, that only supports a single active\n * subscriber. (Useful for testing stream operators and sinks.)\n *\n * Created using {@link mockSource}().\n *\n * @category Types and Interfaces\n */\nexport interface MockSource<T> extends Emitter<T> {\n ready: Backpressure\n}\n\n/**\n * Like {@link emitter}, but with a ready() backpressure method. It also only\n * supports a single active subscriber. (Useful for testing stream operators\n * and sinks.)\n *\n * @category Stream Producers\n */\nexport function mockSource<T>(): MockSource<T> {\n let write: Sink<T>, outlet: Connection, ready: Backpressure;\n const emit: MockSource<T> = (val: T) => { if (write) write(val); };\n emit.source = (sink, conn, inlet) => {\n write = sink; outlet = conn; ready = backpressure(inlet);\n must(() => write = outlet = ready = undefined);\n return IsStream;\n };\n emit.end = () => outlet?.return();\n emit.throw = (e: any) => outlet?.throw(e);\n emit.ready = (cb?: () => any) => ready(cb);\n return emit;\n}\n\n/**\n * A stream that never emits or closes\n *\n * @category Stream Producers\n */\nexport function never(): Source<never> {\n return () => IsStream;\n}\n\n/**\n * Wrap a source to allow multiple subscribers to the same underlying stream\n *\n * The input source will be susbcribed when the output has at least one\n * subscriber, and unsubscribed when the output has no subscribers. The input\n * will be paused when any subscriber pauses, and will only be resumed when all\n * subscribers are unpaused. All subscribers are closed or thrown if the input\n * source closes or throws.\n *\n * (Generally speaking, you should place the share call as late in your\n * pipelines as possible, if you use it at all. It adds some overhead that is\n * wasted if the stream doesn't have multiple subscribers, and may be redundant\n * if an upstream source is already shared. It's mainly useful if there is a\n * lot of mapping, filtering, or other complicated processing taking place\n * upstream of the share, and you know for a fact there will be enough\n * subscribers to make it a bottleneck. You should probably also consider\n * putting some {@link slack}() either upstream or downstream of the share, if\n * the upstream supports backpressure.)\n *\n * @category Stream Operators\n */\nexport function share<T>(source: Stream<T>): Source<T> {\n let uplink: Connection;\n const\n links = new Set<[sink: Sink<T>, conn: Connection]>,\n inlets = new Map<Inlet, number>(), // refcounts of incoming inlets\n t = throttle(), // the actual onReady queue\n multi: Inlet = {\n // A multi-connection inlet that requires all downstreams to be ready\n isOpen() { return !uplink?.result(); },\n isReady() {\n if (this.isOpen()) {\n for (const [i] of inlets) if (!i.isReady()) return (t.pause(), false);\n return true;\n }\n t.pause();\n return false;\n },\n onReady(cb, job) {\n if (this.isOpen()) {\n t.onReady(cb, job);\n for (const [i] of inlets) i.isReady() || i.onReady(produce, job);\n }\n return this;\n }\n }\n ;\n function produce() { multi.isReady() && t.resume(); }\n\n return (sink, conn=start(), inlet) => {\n const self: [Sink<T>, Connection] = [sink, conn];\n links.add(self);\n if (inlet) inlets.set(inlet, 1+(inlets.get(inlet) || 0));\n conn.must(() => {\n links.delete(self);\n if (inlet) {\n inlets.set(inlet, inlets.get(inlet)-1);\n if (!inlets.get(inlet)) inlets.delete(inlet);\n }\n if (!links.size) uplink?.end();\n else if (multi.isReady() && !t.isReady()) defer(produce);\n });\n if (links.size === 1) {\n uplink = detached.connect(source, v => {\n for(const [s, c] of links) try { s(v) } catch(e) { c.throw(e); };\n }, multi).do(r => {\n uplink = undefined;\n if (isCancel(r)) return;\n if (isUnhandled(r)) markHandled(r);\n for(const [_, c] of links) isError(r) ? c.throw(r.err) : c.return();\n })\n }\n return IsStream;\n }\n}\n","import { Job, RecalcSource, Request, Suspend, Yielding } from \"./types.ts\"\nimport { defer } from \"./defer.ts\";\nimport { Connection, Inlet, Sink, Stream, connect, pipe, throttle } from \"./streams.ts\";\nimport { resolve, isError, markHandled, fulfillPromise, rejecter, resolver } from \"./results.ts\";\nimport { restarting, start } from \"./jobutils.ts\";\nimport { isFunction } from \"./utils.ts\";\nimport { Signal, until } from \"./signals.ts\"; // the until is needed for documentation link\nimport { callOrWait, mustBeSourceOrSignal } from \"./call-or-wait.ts\";\nimport { current } from \"./ambient.ts\";\n\n/**\n * The result type returned from calls to {@link Each}.next()\n *\n * @category Types and Interfaces\n */\nexport type EachResult<T> = {\n /** The value provided by the source being iterated */\n item: T;\n\n /**\n * A suspend callback that must be `yield`-ed before the next call to the\n * iterator's .next() method. (That is, you must `yield next` it exactly once\n * per loop pass. See {@link each}() for more details.)\n */\n next: Suspend<void>;\n}\n\n/**\n * The iterable returned by `yield *` {@link each}()\n *\n * @category Types and Interfaces\n */\nexport type Each<T> = IterableIterator<EachResult<T>>\n\n/**\n * Asynchronously iterate over an event source\n *\n * Usage:\n *\n * ```ts\n * for (const {item: event, next} of yield *each(mouseMove)) {\n * console.log(event.clientX, event.clientY);\n * yield next; // required exactly once per iteration, even/w continue!\n * }\n * ```\n *\n * each(eventSource) yield-returns an iterator of `{item, next}` pairs. The\n * item is the data supplied by the event source, and `next` is a\n * {@link Suspend}\\<void\\> that advances the iterator to the next item. It\n * *must* be yielded exactly once per loop iteration. If you use `continue` to\n * shortcut the loop body, you must `yield next` *before* doing so.\n *\n * The for-loop will end if the source ends, errors, or is canceled. The source\n * is paused while the loop body is running, and resumed when the `yield next`\n * happens. If events arrive anyway (e.g. because the source doesn't support\n * pausing), they will be ignored unless you pipe the source through the\n * {@link slack}() operator to provide a buffer. If the for-loop is exited\n * early for any reason (or the iterator's `.return()` is called), the source is\n * unsubscribed and the iteration ended.\n *\n * @category Stream Consumers\n */\nexport function *each<T>(src: Stream<T>): Yielding<Each<T>> {\n let yielded = false, waiter: Request<void>;\n const result: IteratorYieldResult<EachResult<T>> = {value: {item: undefined as T, next}, done: false};\n const t = throttle(), conn = connect(src, v => {\n t.pause();\n if (!waiter || conn.result()) return;\n result.value.item = v;\n resolve(waiter, waiter = void 0);\n }, t).do(r => {\n // Prevent unhandled throws from here - it'll be seen by the next `yield\n // next`, or in the next microtask if `yield next` is already running.\n if (isError(r)) markHandled(r);\n if (waiter) { defer(next.bind(null, waiter)); waiter = undefined; }\n });\n\n // Wait for first value to arrive (and get put in result) before returning the iterator\n t.pause(); yield next;\n return {\n [Symbol.iterator]() { return this; },\n next() {\n if (!yielded) throw new Error(\"Must `yield next` in loop\");\n yielded = false;\n return result;\n },\n return() { conn.end(); return {value: undefined, done: true}; },\n }\n function next(r: Request<void>) {\n if (waiter) throw new Error(\"Multiple `yield next` in loop\");\n yielded = true;\n if (conn.result()) {\n result.value = undefined;\n (result as IteratorResult<any>).done = true;\n fulfillPromise(resolver(r), rejecter(r), conn.result())\n } else {\n waiter = r;\n t.resume();\n }\n }\n}\n\n/**\n * An object that can be waited on with `yield *until()`, by calling its\n * \"uneventful.until\" method. (This mostly exists to allow Signals to optimize\n * their until() implementation, but is also open for extensions.)\n *\n * @category Types and Interfaces\n */\nexport interface UntilMethod<T> {\n /** Return an async op to resume once a truthy value is available */\n \"uneventful.until\"(): Yielding<T>\n}\n\n/**\n * An object that can be waited on with `yield *next()`, by calling its\n * \"uneventful.next\" method. (This mostly exists to allow Signals to optimize\n * their next() implementation, but is also open for extensions.)\n *\n * @category Types and Interfaces\n */\nexport interface NextMethod<T> {\n /** Return an async op to resume with the \"next\" (i.e. not current) value produced */\n \"uneventful.next\"(): Yielding<T>\n};\n\n/**\n * Wait for and return the next value (or error) from a data source (when\n * processed with `yield *` within a {@link Job}).\n *\n * This differs from {@link until}() in that it waits for the *next* value\n * (truthy or not!), and it never resumes immediately for signals, but instead\n * waits for the signal to *change*. (Also, it does not support zero-argument\n * functions, unless you wrap them with {@link cached}() first.)\n *\n * @param source The source to wait on, which can be:\n * - An object with an `\"uneventful.next\"` method returning a {@link Yielding}\n * (in which case the result will be the the result of calling that method)\n * - A {@link Signal} or {@link Source} (in which case the job resumes on the\n * next value it produces)\n *\n * (Note: if the supplied source is a function with a non-zero `.length`, it is\n * assumed to be a {@link Source}.)\n *\n * @returns a Yieldable that when processed with `yield *` in a job, will return\n * the triggered event, or signal value. An error is thrown if event stream\n * throws or closes early, or the signal throws.\n *\n * @category Stream Consumers\n * @category Scheduling\n */\nexport function next<T>(source: NextMethod<T> | Stream<T>): Yielding<T> {\n return callOrWait<T>(source, \"uneventful.next\", waitAny, mustBeSourceOrSignal);\n}\n\nfunction waitAny<T>(job: Job<T>, v: T) { job.return(v); }\n\n/**\n * Run a {@link restarting}() callback for each value produced by a source.\n *\n * With each event that occurs, any previous callback run is cleaned up before\n * the new one begins. (And the last run is cleaned up when the connection or\n * job ends.)\n *\n * This function is almost the exact opposite of {@link each}(), in that the\n * stream is never paused (unless you do so manually via a throttle or inlet),\n * and if the \"loop body\" (callback job) is still running when a new value\n * arrives, forEach() restarts the job instead of dropping the value.\n *\n * @param src An event source (i.e. a {@link Source} or {@link Signal})\n * @param sink A callback that receives values from the source\n * @param inlet An optional throttle or inlet that will be used to pause the\n * source (if it's a signal or supports backpressure)\n * @returns a {@link Connection} that can be used to detect the stream\n * end/error, or ended to close it early.\n *\n * @category Stream Consumers\n */\nexport function forEach<T>(src: Stream<T>, sink: Sink<T>, inlet?: Inlet): Connection;\n/**\n * When called without a source, return a callback suitable for use w/{@link pipe}().\n * e.g.:\n *\n * ```ts\n * pipe(someSource, ..., forEach(v => { doSomething(v); }), optionalInlet));\n * ```\n *\n */\nexport function forEach<T>(sink: Sink<T>, inlet?: Inlet): (src: Stream<T>) => Connection;\nexport function forEach<T>(\n src: Stream<T>|Sink<T>, sink?: Sink<T>|Inlet, inlet?: Inlet\n): Connection | ((src: Stream<T>) => Connection) {\n if (isFunction(sink)) return start(j => {\n (src as Stream<T>)(restarting(sink as Sink<T>), j, inlet)\n });\n inlet = sink as Inlet; sink = src as Sink<T>;\n return (src: Stream<T>) => forEach(src, sink as Sink<T>, inlet);\n}\n\n/**\n * Arrange for the current signal or rule to recalculate on demand\n *\n * This lets you interop with systems that have a way to query a value and\n * subscribe to changes to it, but not directly produce a signal. (Such as\n * querying the DOM state and using a MutationObserver.)\n *\n * By calling this with a {@link Source} or {@link RecalcSource}, you arrange\n * for it to be subscribed, if and when the call occurs in a rule or a cached\n * function that's in use by a rule (directly or indirectly). When the source\n * emits a value, the signal machinery will invalidate the caching of the\n * function or rule, forcing a recalculation and subsequent rule reruns, if\n * applicable.\n *\n * Note: you should generally only call the 1-argument version of this function\n * with \"static\" sources - i.e. ones that won't change on every call. Otherwise,\n * you will end up creating new signals each time, subscribing and unsubscribing\n * on every call to recalcWhen().\n *\n * If the source needs to reference some object, it's best to use the 2-argument\n * version (i.e. `recalcWhen(someObj, factory)`, where `factory` is a function\n * that takes `someObj` and returns a suitable {@link RecalcSource}.)\n *\n * @remarks\n * recalcWhen is specifically designed so that using it does not pull in any\n * part of Uneventful's signals framework, in the event a program doesn't\n * already use it. This means you can use it in library code to provide signal\n * compatibility, without adding bundle bloat to code that doesn't use signals.\n *\n * @category Signals\n */\n\nexport function recalcWhen(src: RecalcSource): void;\n/**\n * Two-argument variant of recalcWhen\n *\n * In certain circumstances, you may wish to use recalcWhen with a source\n * related to some object. You could call recalcWhen with a closure, but that\n * would create and discard signals on every call. So this 2-argument version\n * lets you avoid that by allowing the use of an arbitrary object as a key,\n * along with a factory function to turn the key into a {@link RecalcSource}.\n *\n * @param key an object to be used as a key\n *\n * @param factory a function that will be called with the key to obtain a\n * {@link RecalcSource}. (Note that this factory function must also be a static\n * function, not a closure, or the same memory thrash issue will occur!)\n */\nexport function recalcWhen<T extends WeakKey>(key: T, factory: (key: T) => RecalcSource): void;\nexport function recalcWhen<T extends WeakKey>(fnOrKey: T | RecalcSource, fn?: (key: T) => RecalcSource) {\n current.cell?.recalcWhen<T>(fnOrKey as T, fn);\n}\n","import { fromIterable } from \"./sources.ts\";\nimport { Connection, IsStream, Source, Sink, Stream, Transformer, backpressure, throttle } from \"./streams.ts\";\nimport { isValue, noop } from \"./results.ts\";\nimport { start } from \"./jobutils.ts\";\n\n/**\n * Output multiple streams' contents in order (from an array/iterable of stream\n * sources)\n *\n * Streams are concatenated in order -- note that this means they need to not be\n * infinite if any subsequent streams are to be processed! The output is closed\n * when all sources are finished or if any source throws (in which case the\n * error propagates to the subscriber).\n *\n * Note: this function is just shorthand for {@link concatAll}({@link fromIterable}(*sources*)).\n *\n * @category Stream Operators\n */\nexport function concat<T>(sources: Stream<T>[] | Iterable<Stream<T>>): Source<T> {\n return concatAll(fromIterable(sources))\n}\n\n/**\n * Flatten a source of sources by emitting their contents in series\n *\n * Streams are concatenated in order -- note that this means they need to not be\n * infinite if any subsequent streams are to be processed! The output is closed\n * when all sources are finished or if any source throws (in which case the\n * error propagates to the subscriber).\n *\n * If you want to switch to a new stream whenever a new source arrives from the\n * input stream, use {@link switchAll} instead.\n *\n * @category Stream Operators\n */\nexport function concatAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n let inner: Connection;\n const inputs: Stream<T>[] = [], t = throttle();\n let outer = conn.connect(sources, s => {\n inputs.push(s); startNext(); t.pause();\n }, t).do(r => {\n outer = undefined\n inputs.length || inner || !isValue(r) || conn.return();\n });\n function startNext() {\n inner ||= conn.connect(inputs.shift(), sink, inlet).do(r => {\n inner = undefined;\n inputs.length ? startNext() : (outer ? t.resume() : !isValue(r) || conn.return());\n });\n }\n return IsStream;\n }\n}\n\n/**\n * Map each value of a stream to a substream, then concatenate the resulting\n * substreams\n *\n * (This is just shorthand for `compose(map(mapper), concatAll)`.)\n *\n * If you want to switch to a new stream whenever a new event arrives on the\n * input stream, use {@link switchMap} instead.\n *\n * @category Stream Operators\n */\nexport function concatMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => concatAll(map(mapper)(src))\n}\n\n\n/**\n * Create a subset of a stream, based on a filter function (like Array.filter)\n *\n * The filter function receives the current index (zero-based) as well as the\n * current value. If it returns truth, the value will be passed to the output,\n * otherwise it will be skipped.\n *\n * If the filter function is typed as a Typescript type guard (i.e. as returning\n * `v is SomeType`), then the resulting source will be typed as\n * Source<SomeType>.\n *\n * @category Stream Operators\n */\nexport function filter<T,R extends T>(filter: (v: T, idx: number) => v is R): Transformer<T,R>;\nexport function filter<T>(filter: (v: T, idx: number) => boolean): Transformer<T>;\nexport function filter<T>(filter: (v: T, idx: number) => boolean): Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0; return src(v => filter(v, idx++) && sink(v), conn, inlet);\n }\n}\n\n/**\n * Replace each value in a stream using a function (like Array.map)\n *\n * The mapping function receives the current index (zero-based) as well as the\n * current value.\n *\n * @category Stream Operators\n */\nexport function map<T,R>(mapper: (v: T, idx: number) => R): Transformer<T,R> {\n return src => (sink, conn, inlet) => {\n let idx = 0; return src(v => sink(mapper(v, idx++)), conn, inlet);\n }\n}\n\n/**\n * Create an event source by merging an array or iterable of event sources.\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * @category Stream Operators\n */\nexport function merge<T>(sources: Stream<T>[] | Iterable<Stream<T>>): Source<T> {\n return mergeAll(fromIterable(sources));\n}\n\n/**\n * Create an event source by merging sources from a stream of event sources\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * @category Stream Operators\n */\nexport function mergeAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const uplinks: Set<Connection> = new Set;\n let outer = conn.connect(sources, (s) => {\n const c = conn.connect(s, sink, inlet).do(r => {\n uplinks.delete(c);\n uplinks.size || outer || !isValue(r) || conn.return();\n });\n uplinks.add(c);\n }).do(r => {\n outer = undefined;\n uplinks.size || !isValue(r) || conn.return();\n });\n return IsStream;\n }\n}\n\n/**\n * Create an event source by merging sources created by mapping events to sources\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * (Note: this is just shorthand for `compose(map(mapper), mergeAll)`.)\n *\n * @category Stream Operators\n */\nexport function mergeMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => mergeAll(map(mapper)(src));\n}\n\n/**\n * Skip the first N items from a source\n *\n * (Equivalent to {@link skipWhile}() with a function that checks the index is < n.)\n *\n * @category Stream Operators\n */\nexport function skip<T>(n: number): Transformer<T> {\n return skipWhile((_, i) => i<n);\n}\n\n/**\n * Skip items from a stream until another source produces a value.\n *\n * If the notifier closes without producing a value, the output will\n * be empty. If the notifier throws, so will the output.\n *\n * @category Stream Operators\n */\nexport function skipUntil<T>(notifier: Stream<any>): Transformer<T> {\n return src => (sink, conn=start(), inlet) => {\n let taking = false;\n const c = conn.connect(notifier, () => { taking = true; c.end(); });\n return src(v => taking && sink(v), conn, inlet);\n }\n}\n\n/**\n * Skip items from a stream until a given condition is false, then output all\n * remaining items. The condition function is not called again once it returns\n * false.\n *\n * @category Stream Operators\n */\nexport function skipWhile<T>(condition: (v: T, index: number) => boolean) : Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0, met = false;\n return src(v => (met ||= !condition(v, idx++)) && sink(v), conn, inlet);\n };\n}\n\n/**\n * Add job control and buffering to a stream\n *\n * This lets you block events from a stream that can't be paused, or allow for\n * some slack for a source that can sometimes get ahead of its sink.\n *\n * @param size The number of items to buffer when the sink is busy (i.e., the\n * sink is running or the connection is paused). If positive, the most recent N\n * items are kept (a \"sliding\" buffer), and if negative, the oldest N item are\n * kept (a \"dropping\" buffer). If zero, no items are buffered, and items are\n * dropped if received while the sink is busy.\n *\n * @param dropped Optional: a callback that will receive items when they are\n * dropped. (Useful for testing, performance instrumentation, error logging,\n * etc.)\n *\n * @category Stream Operators\n */\nexport function slack<T>(size: number, dropped: Sink<T> = noop): Transformer<T> {\n const max = Math.abs(size);\n return src => (sink, conn=start(), inlet) => {\n const buffer: T[] = [], ready = backpressure(inlet);\n let paused = false, draining = false;\n const t = throttle();\n conn.connect(src, v => {\n buffer.push(v);\n if (!draining && ready()) return drain();\n while (buffer.length > max) { dropped((size < 0) ? buffer.pop() : buffer.shift()); }\n if (buffer.length === max) { t.pause(); paused = true; }\n if (buffer.length) ready(drain);\n }, t).do(r => {\n if (isValue(r)) conn.return();\n });\n\n function drain() {\n draining = true;\n try {\n while(buffer.length) {\n sink(buffer.shift());\n if (paused && ready()) {\n paused = false; t.resume();\n }\n if (buffer.length && !ready()) {\n return ready(drain);\n }\n }\n } finally {\n draining = false;\n }\n }\n return IsStream;\n }\n}\n\n/**\n * Flatten a source of sources by emitting their contents until a new one\n * arrives.\n *\n * As each source arrives from the input stream, its values are sent to the\n * output, closing the previous one (if any). The output is closed when both\n * the input stream and the most-recently-arrived stream are finished. Errors\n * propagate to the output if any stream throws.\n *\n * (If you want to send *all* the values of each stream to the output without\n * stopping, input stream, use {@link concatAll} or {@link mergeAll} instead.)\n *\n * @category Stream Operators\n */\nexport function switchAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n let inner: Connection;\n let outer = conn.connect(sources, s => {\n inner?.end();\n inner = conn.connect(s, sink, inlet).do(r => {\n inner = undefined;\n outer || !isValue(r) || conn.return();\n });\n }).do(r => {\n outer = undefined;\n inner || !isValue(r) || conn.return();\n });\n return IsStream;\n }\n}\n\n/**\n * Map each value of a stream to a substream, then output the resulting\n * substreams until a new value arrives.\n *\n * (This is just shorthand for `compose(map(mapper),`{@link switchAll `switchAll)`}.)\n *\n * (If you want to send *all* the values of each stream to the output without\n * stopping, input stream, use {@link concatMap} or {@link mergeMap} instead.)\n *\n * @category Stream Operators\n */\nexport function switchMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => switchAll(map(mapper)(src))\n}\n\n/**\n * Take the first N items from a source\n *\n * (Equivalent to {@link takeWhile}() with a function that checks the index is < n.)\n *\n * @category Stream Operators\n */\nexport function take<T>(n: number): Transformer<T> {\n return takeWhile((_, i) => i<n);\n}\n\n/**\n * Take items from a source until another source produces a value.\n *\n * If the notifier closes without producing a value, this will output all\n * elements of the input. But if the notifier throws, so will the output.\n *\n * @category Stream Operators\n */\nexport function takeUntil<T>(notifier: Stream<any>): Transformer<T> {\n return src => (sink, conn=start(), inlet) => {\n conn.connect(notifier, () => conn.return());\n return src(sink, conn, inlet);\n }\n}\n\n/**\n * Take items from a stream until a given condition is false, then close the\n * output. The condition function is not called again after it returns false.\n *\n * If the condition function is typed as a Typescript type guard (i.e. as\n * returning `v is SomeType`), then the resulting source will be typed as\n * Source<SomeType>.\n *\n * @category Stream Operators\n */\nexport function takeWhile<T,R extends T>(condition: (v: T, idx: number) => v is R): Transformer<T,R>;\nexport function takeWhile<T>(condition: (v: T, idx: number) => boolean): Transformer<T>;\nexport function takeWhile<T>(condition: (v: T, index: number) => boolean) : Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0;\n return src(v => condition(v, idx++) ? sink(v) : conn?.return(), conn, inlet);\n };\n}\n"],"names":[],"mappings":";;;;AACO,UAAU,EAAE,CAAC,CAAC,EAAE;AACvB,EAAE,OAAO,MAAM,CAAC,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9E,CAAC;AACM,UAAU,KAAK,CAAC,EAAE,EAAE;AAC3B,EAAE,IAAI;AACN,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,MAAM,CAAC,CAAC,KAAK;AACjB,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM;AAC5B,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC;AACpB,QAAQ,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAC3B,OAAO,EAAE,EAAE,CAAC,CAAC;AACb,KAAK,CAAC;AACN,GAAG,SAAS;AACZ,IAAI,IAAI,EAAE;AACV,MAAM,YAAY,CAAC,EAAE,CAAC,CAAC;AACvB,GAAG;AACH;;ACXO,SAAS,OAAO,GAAG;AAC1B,EAAE,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;AAC5B,EAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnC,EAAE,OAAO,IAAI,CAAC;AACd,CAAC;AACM,SAAS,KAAK,GAAG;AACxB,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,MAAM,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AACM,SAAS,iBAAiB,CAAC,QAAQ,EAAE;AAC5C,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,KAAK,EAAE,EAAE,KAAK,KAAK;AAC1C,IAAI,MAAM,K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K,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACnF,GAAG,CAAC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"mod.mjs","sources":["../src/async.ts","../src/sources.ts","../src/sinks.ts","../src/operators.ts"],"sourcesContent":["import { Request, Yielding } from \"./types.ts\";\nimport { rejecter, resolve, resolver } from \"./results.ts\"\n\n/**\n * Convert a (possible) promise to something you can `yield *to()` in a job\n *\n * Much like `await valueOrPromiseLike` in an async function, using `yield\n * *to(valueOrPromiseLike)` in a {@link Job}'s generator function will return\n * the value or the result of the promise/promise-like object.\n *\n * @category Scheduling\n */\nexport function *to<T>(p: Promise<T> | PromiseLike<T> | T): Yielding<T> {\n return yield (res: Request<T>) => Promise.resolve(p).then(resolver(res), rejecter(res));\n}\n\n/**\n * Pause the job for the specified time in ms, e.g. `yield *sleep(1000)` to wait\n * one second.\n *\n * @category Scheduling\n */\nexport function *sleep(ms: number): Yielding<void> {\n try {\n var id: ReturnType<typeof setTimeout>;\n yield r => {\n id = setTimeout(() => { id = undefined; resolve(r, void 0); }, ms);\n }\n } finally {\n if (id) clearTimeout(id);\n }\n}\n","import { defer } from \"./defer.ts\";\nimport { type Stream, IsStream, backpressure, Sink, Connection, Backpressure, throttle, Inlet, Source } from \"./streams.ts\";\nimport { getJob, detached } from \"./tracking.ts\";\nimport { must, start } from \"./jobutils.ts\";\nimport { DisposeFn } from \"./types.ts\";\nimport { isCancel, isError, isUnhandled, markHandled, noop } from \"./results.ts\";\n\n/**\n * A function that emits events, with a .source they're emitted from\n *\n * Created using {@link emitter}.\n *\n * @category Types and Interfaces\n */\nexport interface Emitter<T> {\n /** Call the emitter to emit events on its .source */\n (val: T): void;\n /** An event source that receives the events */\n source: Source<T>;\n /** Close all current subscribers' connections */\n end: () => void;\n /** Close all current subscribers' connections with an error */\n throw: (e: any) => void;\n};\n\n/**\n * Create an event source and a function to emit events on it\n *\n * (Note: you must specify the event type (e.g. `emitter<number>()`), since\n * there's nothing else to infer it from.)\n *\n * @returns A function that emits events, with a .source property they're\n * emitted on.\n *\n * @category Stream Producers\n */\nexport function emitter<T>(): Emitter<T> {\n const emit = mockSource<T>();\n emit.source = share(emit.source);\n return emit;\n}\n\n/**\n * A stream that immediately closes\n *\n * @category Stream Producers\n */\nexport function empty(): Source<never> {\n return (_, conn) => (conn?.return(), IsStream);\n}\n\n/**\n * Convert an async iterable to an event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * each item output by the iterator, then end the stream. Pause/resume is\n * supported.\n *\n * @category Stream Producers\n */\nexport function fromAsyncIterable<T>(iterable: AsyncIterable<T>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const ready = backpressure(inlet);\n const iter = iterable[Symbol.asyncIterator]();\n if (iter.return) must(() => iter.return());\n return ready(next), IsStream;\n function next() {\n iter.next().then(({value, done}) => {\n if (done) conn.return(); else ready(() => {\n if (sink(value), ready()) next(); else ready(next);\n })\n }, e => conn.throw(e));\n }\n }\n}\n\n/**\n * Create an event source from an element, window, or other event target\n *\n * You can manually override the expected event type using a type parameter,\n * e.g. `fromDomEvent<CustomEvent>(someTarget, \"custom-event\")`.\n *\n * @param target an HTMLElement, Window, Document, or other EventTarget.\n * @param type the name of the event to add a listener for\n * @param options a boolean capture option, or an object of event listener\n * options\n * @returns a source that can be subscribed or piped, issuing events from the\n * target of the specified type.\n *\n * @category Stream Producers\n */\nexport function fromDomEvent<T extends HTMLElement, K extends keyof HTMLElementEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<HTMLElementEventMap[K]>;\nexport function fromDomEvent<T extends Window, K extends keyof WindowEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<WindowEventMap[K]>;\nexport function fromDomEvent<T extends Document, K extends keyof DocumentEventMap>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<DocumentEventMap[K]>;\nexport function fromDomEvent<T extends Event>(\n target: EventTarget, type: string, options?: boolean | AddEventListenerOptions\n): Source<T>\nexport function fromDomEvent<T extends EventTarget, K extends string>(\n target: T, type: K, options?: boolean | AddEventListenerOptions\n): Source<Event> {\n return (sink) => {\n function push(v: Event) { sink(v); }\n target.addEventListener(type, push, options);\n must(() => target.removeEventListener(type, push, options));\n return IsStream;\n }\n}\n\n/**\n * Convert an iterable to a synchronous event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * each item in the iterator, then close the connection. Pause/resume is\n * supported.\n *\n * @category Stream Producers\n */\nexport function fromIterable<T>(iterable: Iterable<T>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const ready = backpressure(inlet);\n const iter = iterable[Symbol.iterator]();\n if (iter.return) must(() => iter.return());\n return ready(loop), IsStream;\n function loop() {\n try {\n for(;;) {\n const {value, done} = iter.next();\n if (done) return conn.return();\n if (sink(value), !ready()) return ready(loop);\n }\n } catch (e) {\n conn.throw(e);\n }\n }\n }\n}\n\n/**\n * Convert a Promise to an event source\n *\n * Each time the resulting source is subscribed to, it will emit an event for\n * the result of the promise, then close the connection. (Unless the promise is\n * rejected, in which case the connection throws and closes each time the source\n * is subscribed.) Non-native promises and non-promise values are converted\n * using Promise.resolve().\n *\n * @category Stream Producers\n */\nexport function fromPromise<T>(promise: Promise<T>|PromiseLike<T>|T): Source<T> {\n return (sink, conn) => {\n const job = getJob();\n Promise.resolve(promise).then(\n v => void (job.result() || (sink(v), conn?.return())),\n e => void (job.result() || conn?.throw(e))\n )\n return IsStream;\n }\n}\n\n/**\n * Create an event source from an arbitrary subscribe/unsubscribe function\n *\n * The supplied \"subscribe\" function will be passed a 1-argument callback and\n * must return an unsubscribe function. The callback should be called with\n * events of the appropriate type, and the unsubscribe function will be called\n * when the connection is closed.\n *\n * (Note: it's okay if the act of subscribing causes an immediate callback, as\n * the subscribe function will be called in a separate microtask.)\n *\n * @category Stream Producers\n */\nexport function fromSubscribe<T>(subscribe: (cb: (val: T) => void) => DisposeFn): Source<T> {\n return (sink) => {\n const f = getJob().must(() => sink = noop);\n return defer(() => f.must(subscribe(v => { sink(v); }))), IsStream;\n }\n}\n\n/**\n * Create a source that emits a single given value\n *\n * @category Stream Producers\n */\nexport function fromValue<T>(val: T): Source<T> {\n return (sink, conn) => {\n must(() => { sink = noop; conn = undefined; })\n return defer(() => { sink(val); conn?.return(); }), IsStream;\n }\n}\n\n/**\n * Create an event source that issues a number every `ms` milliseconds (starting\n * with 0 after the first interval passes).\n *\n * @category Stream Producers\n */\nexport function interval(ms: number): Source<number> {\n return (sink) => {\n let idx = 0, id = setInterval(() => sink(idx++), ms);\n return must(() => clearInterval(id)), IsStream;\n }\n}\n\n/**\n * Create a dynamic source that is created each time it's subscribed\n *\n * @param factory A function returning a source of the desired type. It will be\n * called whenever the lazy() stream is subscribed, and its result subscribed to.\n *\n * @returns A stream of the same type as the factory function returns\n *\n * @category Stream Producers\n */\nexport function lazy<T>(factory: () => Stream<T>): Source<T> {\n return (sink, conn, inlet) => factory()(sink, conn, inlet)\n}\n\n/**\n * An {@link Emitter} with a ready() method, that only supports a single active\n * subscriber. (Useful for testing stream operators and sinks.)\n *\n * Created using {@link mockSource}().\n *\n * @category Types and Interfaces\n */\nexport interface MockSource<T> extends Emitter<T> {\n ready: Backpressure\n}\n\n/**\n * Like {@link emitter}, but with a ready() backpressure method. It also only\n * supports a single active subscriber. (Useful for testing stream operators\n * and sinks.)\n *\n * @category Stream Producers\n */\nexport function mockSource<T>(): MockSource<T> {\n let write: Sink<T>, outlet: Connection, ready: Backpressure;\n const emit: MockSource<T> = (val: T) => { if (write) write(val); };\n emit.source = (sink, conn, inlet) => {\n write = sink; outlet = conn; ready = backpressure(inlet);\n must(() => write = outlet = ready = undefined);\n return IsStream;\n };\n emit.end = () => outlet?.return();\n emit.throw = (e: any) => outlet?.throw(e);\n emit.ready = (cb?: () => any) => ready(cb);\n return emit;\n}\n\n/**\n * A stream that never emits or closes\n *\n * @category Stream Producers\n */\nexport function never(): Source<never> {\n return () => IsStream;\n}\n\n/**\n * Wrap a source to allow multiple subscribers to the same underlying stream\n *\n * The input source will be susbcribed when the output has at least one\n * subscriber, and unsubscribed when the output has no subscribers. The input\n * will be paused when any subscriber pauses, and will only be resumed when all\n * subscribers are unpaused. All subscribers are closed or thrown if the input\n * source closes or throws.\n *\n * (Generally speaking, you should place the share call as late in your\n * pipelines as possible, if you use it at all. It adds some overhead that is\n * wasted if the stream doesn't have multiple subscribers, and may be redundant\n * if an upstream source is already shared. It's mainly useful if there is a\n * lot of mapping, filtering, or other complicated processing taking place\n * upstream of the share, and you know for a fact there will be enough\n * subscribers to make it a bottleneck. You should probably also consider\n * putting some {@link slack}() either upstream or downstream of the share, if\n * the upstream supports backpressure.)\n *\n * @category Stream Operators\n */\nexport function share<T>(source: Stream<T>): Source<T> {\n let uplink: Connection;\n const\n links = new Set<[sink: Sink<T>, conn: Connection]>,\n inlets = new Map<Inlet, number>(), // refcounts of incoming inlets\n t = throttle(), // the actual onReady queue\n multi: Inlet = {\n // A multi-connection inlet that requires all downstreams to be ready\n isOpen() { return !uplink?.result(); },\n isReady() {\n if (this.isOpen()) {\n for (const [i] of inlets) if (!i.isReady()) return (t.pause(), false);\n return true;\n }\n t.pause();\n return false;\n },\n onReady(cb, job) {\n if (this.isOpen()) {\n t.onReady(cb, job);\n for (const [i] of inlets) i.isReady() || i.onReady(produce, job);\n }\n return this;\n }\n }\n ;\n function produce() { multi.isReady() && t.resume(); }\n\n return (sink, conn=start(), inlet) => {\n const self: [Sink<T>, Connection] = [sink, conn];\n links.add(self);\n if (inlet) inlets.set(inlet, 1+(inlets.get(inlet) || 0));\n conn.must(() => {\n links.delete(self);\n if (inlet) {\n inlets.set(inlet, inlets.get(inlet)-1);\n if (!inlets.get(inlet)) inlets.delete(inlet);\n }\n if (!links.size) uplink?.end();\n else if (multi.isReady() && !t.isReady()) defer(produce);\n });\n if (links.size === 1) {\n uplink = detached.connect(source, v => {\n for(const [s, c] of links) try { s(v) } catch(e) { c.throw(e); };\n }, multi).do(r => {\n uplink = undefined;\n if (isCancel(r)) return;\n if (isUnhandled(r)) markHandled(r);\n for(const [_, c] of links) isError(r) ? c.throw(r.err) : c.return();\n })\n }\n return IsStream;\n }\n}\n","import { Job, RecalcSource, Request, Suspend, Yielding } from \"./types.ts\"\nimport { defer } from \"./defer.ts\";\nimport { Connection, Inlet, Sink, Stream, connect, pipe, throttle } from \"./streams.ts\";\nimport { resolve, isError, markHandled, fulfillPromise, rejecter, resolver } from \"./results.ts\";\nimport { restarting, start, must } from \"./jobutils.ts\";\nimport { isFunction } from \"./utils.ts\";\nimport { Signal, until } from \"./signals.ts\"; // the until is needed for documentation link\nimport { callOrWait, mustBeSourceOrSignal } from \"./call-or-wait.ts\";\nimport { current } from \"./ambient.ts\";\n\n/**\n * The result type returned from calls to {@link Each}.next()\n *\n * @category Types and Interfaces\n */\nexport type EachResult<T> = {\n /** The value provided by the source being iterated */\n item: T;\n\n /**\n * A suspend callback that must be `yield`-ed before the next call to the\n * iterator's .next() method. (That is, you must `yield next` it exactly once\n * per loop pass. See {@link each}() for more details.)\n */\n next: Suspend<void>;\n}\n\n/**\n * The iterable returned by `yield *` {@link each}()\n *\n * @category Types and Interfaces\n */\nexport type Each<T> = IterableIterator<EachResult<T>>\n\n/**\n * Asynchronously iterate over an event source\n *\n * Usage:\n *\n * ```ts\n * for (const {item: event, next} of yield *each(mouseMove)) {\n * console.log(event.clientX, event.clientY);\n * yield next; // required exactly once per iteration, even/w continue!\n * }\n * ```\n *\n * each(eventSource) yield-returns an iterator of `{item, next}` pairs. The\n * item is the data supplied by the event source, and `next` is a\n * {@link Suspend}\\<void\\> that advances the iterator to the next item. It\n * *must* be yielded exactly once per loop iteration. If you use `continue` to\n * shortcut the loop body, you must `yield next` *before* doing so.\n *\n * The for-loop will end if the source ends, errors, or is canceled. The source\n * is paused while the loop body is running, and resumed when the `yield next`\n * happens. If events arrive anyway (e.g. because the source doesn't support\n * pausing), they will be ignored unless you pipe the source through the\n * {@link slack}() operator to provide a buffer. If the for-loop is exited\n * early for any reason (or the iterator's `.return()` is called), the source is\n * unsubscribed and the iteration ended.\n *\n * @category Stream Consumers\n */\nexport function *each<T>(src: Stream<T>): Yielding<Each<T>> {\n let yielded = false, waiter: Request<void>;\n const result: IteratorYieldResult<EachResult<T>> = {value: {item: undefined as T, next}, done: false};\n const t = throttle(), conn = connect(src, v => {\n t.pause();\n if (!waiter || conn.result()) return;\n result.value.item = v;\n resolve(waiter, waiter = void 0);\n }, t).do(r => {\n // Prevent unhandled throws from here - it'll be seen by the next `yield\n // next`, or in the next microtask if `yield next` is already running.\n if (isError(r)) markHandled(r);\n if (waiter) { defer(next.bind(null, waiter)); waiter = undefined; }\n });\n\n // Wait for first value to arrive (and get put in result) before returning the iterator\n t.pause(); yield next;\n return {\n [Symbol.iterator]() { return this; },\n next() {\n if (!yielded) throw new Error(\"Must `yield next` in loop\");\n yielded = false;\n return result;\n },\n return() { conn.end(); return {value: undefined, done: true}; },\n }\n function next(r: Request<void>) {\n if (waiter) throw new Error(\"Multiple `yield next` in loop\");\n yielded = true;\n if (conn.result()) {\n result.value = undefined;\n (result as IteratorResult<any>).done = true;\n fulfillPromise(resolver(r), rejecter(r), conn.result())\n } else {\n waiter = r;\n t.resume();\n }\n }\n}\n\n/**\n * An object that can be waited on with `yield *until()`, by calling its\n * \"uneventful.until\" method. (This mostly exists to allow Signals to optimize\n * their until() implementation, but is also open for extensions.)\n *\n * @category Types and Interfaces\n */\nexport interface UntilMethod<T> {\n /** Return an async op to resume once a truthy value is available */\n \"uneventful.until\"(): Yielding<T>\n}\n\n/**\n * An object that can be waited on with `yield *next()`, by calling its\n * \"uneventful.next\" method. (This mostly exists to allow Signals to optimize\n * their next() implementation, but is also open for extensions.)\n *\n * @category Types and Interfaces\n */\nexport interface NextMethod<T> {\n /** Return an async op to resume with the \"next\" (i.e. not current) value produced */\n \"uneventful.next\"(): Yielding<T>\n};\n\n/**\n * Wait for and return the next value (or error) from a data source (when\n * processed with `yield *` within a {@link Job}).\n *\n * This differs from {@link until}() in that it waits for the *next* value\n * (truthy or not!), and it never resumes immediately for signals, but instead\n * waits for the signal to *change*. (Also, it does not support zero-argument\n * functions, unless you wrap them with {@link cached}() first.)\n *\n * @param source The source to wait on, which can be:\n * - An object with an `\"uneventful.next\"` method returning a {@link Yielding}\n * (in which case the result will be the the result of calling that method)\n * - A {@link Signal} or {@link Source} (in which case the job resumes on the\n * next value it produces)\n *\n * (Note: if the supplied source is a function with a non-zero `.length`, it is\n * assumed to be a {@link Source}.)\n *\n * @returns a Yieldable that when processed with `yield *` in a job, will return\n * the triggered event, or signal value. An error is thrown if event stream\n * throws or closes early, or the signal throws.\n *\n * @category Stream Consumers\n * @category Scheduling\n */\nexport function next<T>(source: NextMethod<T> | Stream<T>): Yielding<T> {\n return callOrWait<T>(source, \"uneventful.next\", waitAny, mustBeSourceOrSignal);\n}\n\nfunction waitAny<T>(job: Job<T>, v: T) { job.return(v); }\n\n/**\n * Run a {@link restarting}() callback for each value produced by a source.\n *\n * With each event that occurs, any previous callback run is cleaned up before\n * the new one begins. (And the last run is cleaned up when the connection or\n * job ends.)\n *\n * This function is almost the exact opposite of {@link each}(), in that the\n * stream is never paused (unless you do so manually via a throttle or inlet),\n * and if the \"loop body\" (callback job) is still running when a new value\n * arrives, forEach() restarts the job instead of dropping the value.\n *\n * @param src An event source (i.e. a {@link Source} or {@link Signal})\n * @param sink A callback that receives values from the source\n * @param inlet An optional throttle or inlet that will be used to pause the\n * source (if it's a signal or supports backpressure)\n * @returns a {@link Connection} that can be used to detect the stream\n * end/error, or ended to close it early.\n *\n * @category Stream Consumers\n */\nexport function forEach<T>(src: Stream<T>, sink: Sink<T>, inlet?: Inlet): Connection;\n/**\n * When called without a source, return a callback suitable for use w/{@link pipe}().\n * e.g.:\n *\n * ```ts\n * pipe(someSource, ..., forEach(v => { doSomething(v); }), optionalInlet));\n * ```\n *\n */\nexport function forEach<T>(sink: Sink<T>, inlet?: Inlet): (src: Stream<T>) => Connection;\nexport function forEach<T>(\n src: Stream<T>|Sink<T>, sink?: Sink<T>|Inlet, inlet?: Inlet\n): Connection | ((src: Stream<T>) => Connection) {\n if (isFunction(sink)) return start(j => {\n (src as Stream<T>)(restarting(sink as Sink<T>), j, inlet)\n });\n inlet = sink as Inlet; sink = src as Sink<T>;\n return (src: Stream<T>) => forEach(src, sink as Sink<T>, inlet);\n}\n\n/**\n * Arrange for the current signal or rule to recalculate on demand\n *\n * This lets you interop with systems that have a way to query a value and\n * subscribe to changes to it, but not directly produce a signal. (Such as\n * querying the DOM state and using a MutationObserver.)\n *\n * By calling this with a {@link Source} or {@link RecalcSource}, you arrange\n * for it to be subscribed, if and when the call occurs in a rule or a cached\n * function that's in use by a rule (directly or indirectly). When the source\n * emits a value, the signal machinery will invalidate the caching of the\n * function or rule, forcing a recalculation and subsequent rule reruns, if\n * applicable.\n *\n * Note: you should generally only call the 1-argument version of this function\n * with \"static\" sources - i.e. ones that won't change on every call. Otherwise,\n * you will end up creating new signals each time, subscribing and unsubscribing\n * on every call to recalcWhen().\n *\n * If the source needs to reference some object, it's best to use the 2-argument\n * version (i.e. `recalcWhen(someObj, factory)`, where `factory` is a function\n * that takes `someObj` and returns a suitable {@link RecalcSource}.)\n *\n * @remarks\n * recalcWhen is specifically designed so that using it does not pull in any\n * part of Uneventful's signals framework, in the event a program doesn't\n * already use it. This means you can use it in library code to provide signal\n * compatibility, without adding bundle bloat to code that doesn't use signals.\n *\n * @category Signals\n */\n\nexport function recalcWhen(src: RecalcSource): void;\n/**\n * Two-argument variant of recalcWhen\n *\n * In certain circumstances, you may wish to use recalcWhen with a source\n * related to some object. You could call recalcWhen with a closure, but that\n * would create and discard signals on every call. So this 2-argument version\n * lets you avoid that by allowing the use of an arbitrary object as a key,\n * along with a factory function to turn the key into a {@link RecalcSource}.\n *\n * @param key an object to be used as a key\n *\n * @param factory a function that will be called with the key to obtain a\n * {@link RecalcSource}. (Note that this factory function must also be a static\n * function, not a closure, or the same memory thrash issue will occur!)\n */\nexport function recalcWhen<T extends WeakKey>(key: T, factory: (key: T) => RecalcSource): void;\nexport function recalcWhen<T extends WeakKey>(fnOrKey: T | RecalcSource, fn?: (key: T) => RecalcSource) {\n current.cell?.recalcWhen<T>(fnOrKey as T, fn);\n}\n\n/**\n * Find out whether the active signal is being observed, or just queried.\n *\n * If the return value is true, the caller is running within a signal\n * calculation that is being observed by subscribers (such as a rule or stream\n * listener). If the return value is false, the caller is running within a\n * signal calculation that is *not* observed by any subscribers, and the signal\n * will be recalculated whenever it transitions from unobserved to observed.\n *\n * Returns `undefined` if the caller isn't running in a signal calculation.\n *\n * @remarks Note that calling this function within a signal calculation even\n * once adds a *permanent*, implicit dependency to that signal, on whether the\n * signal is being observed. (As does using any job APIs directly.)\n *\n * The assumption here is that if you're checking whether it's observed, it's\n * because you only want to do certain things *while* it's being observed, so\n * the signal needs to be recalculated when it *starts* being observed, so you\n * can do those things. (If you need to undo or clean up those things when the\n * signal is no-longer observed, you can register a cleanup callback via e.g.\n * {@link must}(), or wrap them in a sub-job with start, connect, etc.)\n *\n * @category Signals\n */\nexport function isObserved(): boolean | undefined {\n return current.cell?.isObserved();\n}\n","import { fromIterable } from \"./sources.ts\";\nimport { Connection, IsStream, Source, Sink, Stream, Transformer, backpressure, throttle } from \"./streams.ts\";\nimport { isValue, noop } from \"./results.ts\";\nimport { start } from \"./jobutils.ts\";\n\n/**\n * Output multiple streams' contents in order (from an array/iterable of stream\n * sources)\n *\n * Streams are concatenated in order -- note that this means they need to not be\n * infinite if any subsequent streams are to be processed! The output is closed\n * when all sources are finished or if any source throws (in which case the\n * error propagates to the subscriber).\n *\n * Note: this function is just shorthand for {@link concatAll}({@link fromIterable}(*sources*)).\n *\n * @category Stream Operators\n */\nexport function concat<T>(sources: Stream<T>[] | Iterable<Stream<T>>): Source<T> {\n return concatAll(fromIterable(sources))\n}\n\n/**\n * Flatten a source of sources by emitting their contents in series\n *\n * Streams are concatenated in order -- note that this means they need to not be\n * infinite if any subsequent streams are to be processed! The output is closed\n * when all sources are finished or if any source throws (in which case the\n * error propagates to the subscriber).\n *\n * If you want to switch to a new stream whenever a new source arrives from the\n * input stream, use {@link switchAll} instead.\n *\n * @category Stream Operators\n */\nexport function concatAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n let inner: Connection;\n const inputs: Stream<T>[] = [], t = throttle();\n let outer = conn.connect(sources, s => {\n inputs.push(s); startNext(); t.pause();\n }, t).do(r => {\n outer = undefined\n inputs.length || inner || !isValue(r) || conn.return();\n });\n function startNext() {\n inner ||= conn.connect(inputs.shift(), sink, inlet).do(r => {\n inner = undefined;\n inputs.length ? startNext() : (outer ? t.resume() : !isValue(r) || conn.return());\n });\n }\n return IsStream;\n }\n}\n\n/**\n * Map each value of a stream to a substream, then concatenate the resulting\n * substreams\n *\n * (This is just shorthand for `compose(map(mapper), concatAll)`.)\n *\n * If you want to switch to a new stream whenever a new event arrives on the\n * input stream, use {@link switchMap} instead.\n *\n * @category Stream Operators\n */\nexport function concatMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => concatAll(map(mapper)(src))\n}\n\n\n/**\n * Create a subset of a stream, based on a filter function (like Array.filter)\n *\n * The filter function receives the current index (zero-based) as well as the\n * current value. If it returns truth, the value will be passed to the output,\n * otherwise it will be skipped.\n *\n * If the filter function is typed as a Typescript type guard (i.e. as returning\n * `v is SomeType`), then the resulting source will be typed as\n * Source<SomeType>.\n *\n * @category Stream Operators\n */\nexport function filter<T,R extends T>(filter: (v: T, idx: number) => v is R): Transformer<T,R>;\nexport function filter<T>(filter: (v: T, idx: number) => boolean): Transformer<T>;\nexport function filter<T>(filter: (v: T, idx: number) => boolean): Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0; return src(v => filter(v, idx++) && sink(v), conn, inlet);\n }\n}\n\n/**\n * Replace each value in a stream using a function (like Array.map)\n *\n * The mapping function receives the current index (zero-based) as well as the\n * current value.\n *\n * @category Stream Operators\n */\nexport function map<T,R>(mapper: (v: T, idx: number) => R): Transformer<T,R> {\n return src => (sink, conn, inlet) => {\n let idx = 0; return src(v => sink(mapper(v, idx++)), conn, inlet);\n }\n}\n\n/**\n * Create an event source by merging an array or iterable of event sources.\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * @category Stream Operators\n */\nexport function merge<T>(sources: Stream<T>[] | Iterable<Stream<T>>): Source<T> {\n return mergeAll(fromIterable(sources));\n}\n\n/**\n * Create an event source by merging sources from a stream of event sources\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * @category Stream Operators\n */\nexport function mergeAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n const uplinks: Set<Connection> = new Set;\n let outer = conn.connect(sources, (s) => {\n const c = conn.connect(s, sink, inlet).do(r => {\n uplinks.delete(c);\n uplinks.size || outer || !isValue(r) || conn.return();\n });\n uplinks.add(c);\n }).do(r => {\n outer = undefined;\n uplinks.size || !isValue(r) || conn.return();\n });\n return IsStream;\n }\n}\n\n/**\n * Create an event source by merging sources created by mapping events to sources\n *\n * The resulting source issues events whenever any of the input sources do, and\n * closes once they all do (or throws if any of them do).\n *\n * (Note: this is just shorthand for `compose(map(mapper), mergeAll)`.)\n *\n * @category Stream Operators\n */\nexport function mergeMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => mergeAll(map(mapper)(src));\n}\n\n/**\n * Skip the first N items from a source\n *\n * (Equivalent to {@link skipWhile}() with a function that checks the index is < n.)\n *\n * @category Stream Operators\n */\nexport function skip<T>(n: number): Transformer<T> {\n return skipWhile((_, i) => i<n);\n}\n\n/**\n * Skip items from a stream until another source produces a value.\n *\n * If the notifier closes without producing a value, the output will\n * be empty. If the notifier throws, so will the output.\n *\n * @category Stream Operators\n */\nexport function skipUntil<T>(notifier: Stream<any>): Transformer<T> {\n return src => (sink, conn=start(), inlet) => {\n let taking = false;\n const c = conn.connect(notifier, () => { taking = true; c.end(); });\n return src(v => taking && sink(v), conn, inlet);\n }\n}\n\n/**\n * Skip items from a stream until a given condition is false, then output all\n * remaining items. The condition function is not called again once it returns\n * false.\n *\n * @category Stream Operators\n */\nexport function skipWhile<T>(condition: (v: T, index: number) => boolean) : Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0, met = false;\n return src(v => (met ||= !condition(v, idx++)) && sink(v), conn, inlet);\n };\n}\n\n/**\n * Add job control and buffering to a stream\n *\n * This lets you block events from a stream that can't be paused, or allow for\n * some slack for a source that can sometimes get ahead of its sink.\n *\n * @param size The number of items to buffer when the sink is busy (i.e., the\n * sink is running or the connection is paused). If positive, the most recent N\n * items are kept (a \"sliding\" buffer), and if negative, the oldest N item are\n * kept (a \"dropping\" buffer). If zero, no items are buffered, and items are\n * dropped if received while the sink is busy.\n *\n * @param dropped Optional: a callback that will receive items when they are\n * dropped. (Useful for testing, performance instrumentation, error logging,\n * etc.)\n *\n * @category Stream Operators\n */\nexport function slack<T>(size: number, dropped: Sink<T> = noop): Transformer<T> {\n const max = Math.abs(size);\n return src => (sink, conn=start(), inlet) => {\n const buffer: T[] = [], ready = backpressure(inlet);\n let paused = false, draining = false;\n const t = throttle();\n conn.connect(src, v => {\n buffer.push(v);\n if (!draining && ready()) return drain();\n while (buffer.length > max) { dropped((size < 0) ? buffer.pop() : buffer.shift()); }\n if (buffer.length === max) { t.pause(); paused = true; }\n if (buffer.length) ready(drain);\n }, t).do(r => {\n if (isValue(r)) conn.return();\n });\n\n function drain() {\n draining = true;\n try {\n while(buffer.length) {\n sink(buffer.shift());\n if (paused && ready()) {\n paused = false; t.resume();\n }\n if (buffer.length && !ready()) {\n return ready(drain);\n }\n }\n } finally {\n draining = false;\n }\n }\n return IsStream;\n }\n}\n\n/**\n * Flatten a source of sources by emitting their contents until a new one\n * arrives.\n *\n * As each source arrives from the input stream, its values are sent to the\n * output, closing the previous one (if any). The output is closed when both\n * the input stream and the most-recently-arrived stream are finished. Errors\n * propagate to the output if any stream throws.\n *\n * (If you want to send *all* the values of each stream to the output without\n * stopping, input stream, use {@link concatAll} or {@link mergeAll} instead.)\n *\n * @category Stream Operators\n */\nexport function switchAll<T>(sources: Stream<Stream<T>>): Source<T> {\n return (sink, conn=start(), inlet) => {\n let inner: Connection;\n let outer = conn.connect(sources, s => {\n inner?.end();\n inner = conn.connect(s, sink, inlet).do(r => {\n inner = undefined;\n outer || !isValue(r) || conn.return();\n });\n }).do(r => {\n outer = undefined;\n inner || !isValue(r) || conn.return();\n });\n return IsStream;\n }\n}\n\n/**\n * Map each value of a stream to a substream, then output the resulting\n * substreams until a new value arrives.\n *\n * (This is just shorthand for `compose(map(mapper),`{@link switchAll `switchAll)`}.)\n *\n * (If you want to send *all* the values of each stream to the output without\n * stopping, input stream, use {@link concatMap} or {@link mergeMap} instead.)\n *\n * @category Stream Operators\n */\nexport function switchMap<T,R>(mapper: (v: T, idx: number) => Stream<R>): Transformer<T,R> {\n return src => switchAll(map(mapper)(src))\n}\n\n/**\n * Take the first N items from a source\n *\n * (Equivalent to {@link takeWhile}() with a function that checks the index is < n.)\n *\n * @category Stream Operators\n */\nexport function take<T>(n: number): Transformer<T> {\n return takeWhile((_, i) => i<n);\n}\n\n/**\n * Take items from a source until another source produces a value.\n *\n * If the notifier closes without producing a value, this will output all\n * elements of the input. But if the notifier throws, so will the output.\n *\n * @category Stream Operators\n */\nexport function takeUntil<T>(notifier: Stream<any>): Transformer<T> {\n return src => (sink, conn=start(), inlet) => {\n conn.connect(notifier, () => conn.return());\n return src(sink, conn, inlet);\n }\n}\n\n/**\n * Take items from a stream until a given condition is false, then close the\n * output. The condition function is not called again after it returns false.\n *\n * If the condition function is typed as a Typescript type guard (i.e. as\n * returning `v is SomeType`), then the resulting source will be typed as\n * Source<SomeType>.\n *\n * @category Stream Operators\n */\nexport function takeWhile<T,R extends T>(condition: (v: T, idx: number) => v is R): Transformer<T,R>;\nexport function takeWhile<T>(condition: (v: T, idx: number) => boolean): Transformer<T>;\nexport function takeWhile<T>(condition: (v: T, index: number) => boolean) : Transformer<T> {\n return src => (sink, conn, inlet) => {\n let idx = 0;\n return src(v => condition(v, idx++) ? sink(v) : conn?.return(), conn, inlet);\n };\n}\n"],"names":[],"mappings":";;;;AACO,UAAU,EAAE,CAAC,CAAC,EAAE;AACvB,EAAE,OAAO,MAAM,CAAC,GAAG,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9E,CAAC;AACM,UAAU,KAAK,CAAC,EAAE,EAAE;AAC3B,EAAE,IAAI;AACN,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,MAAM,CAAC,CAAC,KAAK;AACjB,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM;AAC5B,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC;AACpB,QAAQ,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAC3B,OAAO,EAAE,EAAE,CAAC,CAAC;AACb,KAAK,CAAC;AACN,GAAG,SAAS;AACZ,IAAI,IAAI,EAAE;AACV,MAAM,YAAY,CAAC,EAAE,CAAC,CAAC;AACvB,GAAG;AACH;;ACXO,SAAS,OAAO,GAAG;AAC1B,EAAE,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;AAC5B,EAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnC,EAAE,OAAO,IAAI,CAAC;AACd,CAAC;AACM,SAAS,KAAK,GAAG;AACxB,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,MAAM,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AACM,SAAS,iBAAiB,CAAC,QAAQ,EAAE;AAC5C,E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AS,CAAC,SAAS,EAAE;AACrC,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,KAAK;AACzC,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC;AAChB,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACnF,GAAG,CAAC;AACJ;;;;"}
|
package/dist/signals.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AnyFunction,
|
|
2
|
-
import { U as UntilMethod } from './sinks-
|
|
1
|
+
import { A as AnyFunction, O as OptionalCleanup, D as DisposeFn, L as SignalSource, Y as Yielding, S as Source, P as PlainFunction, a as Stream } from './types-N2ua11te.js';
|
|
2
|
+
import { U as UntilMethod } from './sinks-5TuxCRtX.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A decorator function that supports both TC39 and "legacy" decorator protocols
|
|
@@ -30,7 +30,7 @@ interface RuleFactory {
|
|
|
30
30
|
* @inheritdoc rule factory tied to a specific scheduler. See {@link rule} for
|
|
31
31
|
* more details.
|
|
32
32
|
*/
|
|
33
|
-
(fn: (
|
|
33
|
+
(fn: () => OptionalCleanup): DisposeFn;
|
|
34
34
|
/**
|
|
35
35
|
* A function that will stop the currently-executing rule. (Accessing this
|
|
36
36
|
* attribute will throw an error if no rule is currently running.)
|
|
@@ -138,10 +138,9 @@ interface RuleFactory {
|
|
|
138
138
|
*
|
|
139
139
|
* Note that since the created rule isn't attached to a job, it *must* be
|
|
140
140
|
* explicitly stopped, either by calling the returned disposal function or
|
|
141
|
-
* by the rule function arranging to stop itself via {@link rule.stop}()
|
|
142
|
-
* its stop parameter.
|
|
141
|
+
* by the rule function arranging to stop itself via {@link rule.stop}().
|
|
143
142
|
*/
|
|
144
|
-
detached(fn: (
|
|
143
|
+
detached(fn: () => OptionalCleanup): DisposeFn;
|
|
145
144
|
/**
|
|
146
145
|
* Change the scheduler used for the currently-executing rule. Throws an
|
|
147
146
|
* error if no rule is running.
|
|
@@ -162,29 +161,28 @@ interface RuleFactory {
|
|
|
162
161
|
* Subscribe a function to run every time certain values change.
|
|
163
162
|
*
|
|
164
163
|
* The function is run asynchronously, first after being created, then again
|
|
165
|
-
* after there are changes in any of the
|
|
166
|
-
* during its previous run.
|
|
164
|
+
* after there are changes in any of the {@link value}()s or {@link cached}()
|
|
165
|
+
* functions it read during its previous run.
|
|
167
166
|
*
|
|
168
167
|
* The created subscription is tied to the currently-active job (which may be
|
|
169
168
|
* another rule). So when that job is ended or restarted, the rule will be
|
|
170
169
|
* terminated automatically. You can also terminate it early by calling the
|
|
171
|
-
* "stop" function that is
|
|
172
|
-
*
|
|
170
|
+
* "stop" function that is returned by `rule()`, or by calling
|
|
171
|
+
* {@link rule.stop}() from within the rule function.
|
|
173
172
|
*
|
|
174
173
|
* Note: this function will throw an error if called without an active job. If
|
|
175
174
|
* you need a standalone rule, use {@link RuleFactory.detached rule.detached}().
|
|
176
175
|
*
|
|
177
176
|
* @param fn The function that will be run each time its dependencies change.
|
|
178
177
|
* The function will be run in a restarted job each time, with any resources
|
|
179
|
-
* used by the previous run being cleaned up. The function is
|
|
180
|
-
*
|
|
181
|
-
* should return a cleanup function or void.
|
|
178
|
+
* used by the previous run being cleaned up. The function is called with no
|
|
179
|
+
* arguments, and should return a cleanup function or void.
|
|
182
180
|
*
|
|
183
181
|
* @returns A function that can be called to terminate the rule.
|
|
184
182
|
*
|
|
185
|
-
* @category
|
|
183
|
+
* @category Reactive Behaviors
|
|
186
184
|
*/
|
|
187
|
-
declare const rule: ((
|
|
185
|
+
declare const rule: ((fn: () => OptionalCleanup) => DisposeFn) & RuleFactory;
|
|
188
186
|
/**
|
|
189
187
|
* Synchronously run any pending rules tied to a specific schedule.
|
|
190
188
|
*
|
|
@@ -201,7 +199,7 @@ declare const rule: ((action: (stop: DisposeFn) => OptionalCleanup) => DisposeFn
|
|
|
201
199
|
* factory you wish to run pending rules for. If not given, the default
|
|
202
200
|
* {@link rule}() factory is targeted.
|
|
203
201
|
*
|
|
204
|
-
* @category
|
|
202
|
+
* @category Reactive Behaviors
|
|
205
203
|
*/
|
|
206
204
|
declare function runRules(scheduleFn?: SchedulerFn): void;
|
|
207
205
|
/**
|
|
@@ -233,6 +231,34 @@ declare class WriteConflict extends Error {
|
|
|
233
231
|
*/
|
|
234
232
|
declare class CircularDependency extends Error {
|
|
235
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Keep an expression's old value unless there's a semantic change
|
|
236
|
+
*
|
|
237
|
+
* By default, reactive values (i.e. {@link cached}(), or {@link value}() with a
|
|
238
|
+
* {@link Configurable.setf setf}()) are considered to have "changed" (and thus
|
|
239
|
+
* trigger recalculation of their dependents) when they are different according
|
|
240
|
+
* to `===` comparison.
|
|
241
|
+
*
|
|
242
|
+
* This works well for primitive values, but for arrays and objects it's not
|
|
243
|
+
* always ideal, because two arrays can have the exact same elements and still
|
|
244
|
+
* be different according to `===`. So this function lets you substitute a
|
|
245
|
+
* different comparison function (like a deep-equal or shallow-equal) instead.
|
|
246
|
+
* (The default is {@link arrayEq}() if no compare function is supplied.)
|
|
247
|
+
*
|
|
248
|
+
* Specifically, if your reactive expression returns `unchangedIf(newVal,
|
|
249
|
+
* compare)`, then the expression's previous value will be kept if the compare
|
|
250
|
+
* function returns true when called with the old and new values. Otherwise, the
|
|
251
|
+
* new value will be used.
|
|
252
|
+
*
|
|
253
|
+
* @remarks
|
|
254
|
+
* - If the reactive expression's last "value" was an error, the new value is
|
|
255
|
+
* returned
|
|
256
|
+
* - An error will be thrown if this function is called outside a reactive
|
|
257
|
+
* expression or from within a {@link peek}() call or {@link action} wrapper.
|
|
258
|
+
*
|
|
259
|
+
* @category Reactive Values
|
|
260
|
+
*/
|
|
261
|
+
declare function unchangedIf<T>(newVal: T, equals?: (v1: T, v2: T) => boolean): T;
|
|
236
262
|
|
|
237
263
|
/**
|
|
238
264
|
* The Signals API for uneventful.
|
|
@@ -329,7 +355,7 @@ interface Configurable<T> extends Writable<T> {
|
|
|
329
355
|
/**
|
|
330
356
|
* Create a {@link Configurable} signal with the given inital value
|
|
331
357
|
*
|
|
332
|
-
* @category
|
|
358
|
+
* @category Reactive Values
|
|
333
359
|
*/
|
|
334
360
|
declare function value<T>(val?: T): Configurable<T>;
|
|
335
361
|
/**
|
|
@@ -341,7 +367,7 @@ declare function value<T>(val?: T): Configurable<T>;
|
|
|
341
367
|
* calling signature below will apply, even if TypeScript doesn't see it that
|
|
342
368
|
* way!)
|
|
343
369
|
*
|
|
344
|
-
* @category
|
|
370
|
+
* @category Reactive Values
|
|
345
371
|
*/
|
|
346
372
|
declare function cached<T>(compute: () => T): Signal<T>;
|
|
347
373
|
/**
|
|
@@ -382,7 +408,7 @@ declare function cached<T extends Signal<any>>(signal: T): T;
|
|
|
382
408
|
*
|
|
383
409
|
* @returns The result of calling `fn(..args)`
|
|
384
410
|
*
|
|
385
|
-
* @category
|
|
411
|
+
* @category Reactive Values
|
|
386
412
|
*/
|
|
387
413
|
declare function peek<F extends PlainFunction>(fn: F, ...args: Parameters<F>): ReturnType<F>;
|
|
388
414
|
/**
|
|
@@ -424,7 +450,7 @@ declare function peek<F extends PlainFunction>(fn: F, ...args: Parameters<F>): R
|
|
|
424
450
|
* to the original function, while running with dependency tracking suppressed
|
|
425
451
|
* (as with {@link peek}()).
|
|
426
452
|
*
|
|
427
|
-
* @category
|
|
453
|
+
* @category Reactive Behaviors
|
|
428
454
|
*/
|
|
429
455
|
declare function action<F extends AnyFunction>(fn: F): F;
|
|
430
456
|
/** @hidden TC39 Decorator protocol */
|
|
@@ -462,9 +488,8 @@ declare function action<F extends AnyFunction, D extends {
|
|
|
462
488
|
* the triggered event, or signal value. An error is thrown if event stream
|
|
463
489
|
* throws or closes early, or the signal throws.
|
|
464
490
|
*
|
|
465
|
-
* @category Signals
|
|
466
491
|
* @category Scheduling
|
|
467
492
|
*/
|
|
468
493
|
declare function until<T>(source: UntilMethod<T> | Stream<T> | (() => T)): Yielding<T>;
|
|
469
494
|
|
|
470
|
-
export { CircularDependency, type Configurable, type GenericMethodDecorator, type RuleFactory, type SchedulerFn, type Signal, type Writable, WriteConflict, action, cached, peek, rule, runRules, until, value };
|
|
495
|
+
export { CircularDependency, type Configurable, type GenericMethodDecorator, type RuleFactory, type SchedulerFn, type Signal, type Writable, WriteConflict, action, cached, peek, rule, runRules, unchangedIf, until, value };
|