diff --git a/all/README.md b/all/README.md index d49b0b0..dee506e 100644 --- a/all/README.md +++ b/all/README.md @@ -1,8 +1,8 @@ # [@observable/all](https://jsr.io/@observable/all) -[`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s an +[Pushes](https://jsr.io/@observable/core#push) an [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of -values from _all_ of the given `observables` in +the latest values from _all_ of the given `observables` in [iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol) order. @@ -88,6 +88,57 @@ all([]).subscribe({ // "return" ``` +Iterable of observables + +```ts +import { all } from "@observable/all"; +import { Subject } from "@observable/core"; + +const subject1 = new Subject(); +const subject2 = subject1; +const subject3 = new Subject(); +const controller = new AbortController(); + +all(new Set([subject1, subject2, subject3])).subscribe({ + signal: controller.signal, + next: (value) => console.log("next", value), + return: () => console.log("return"), + throw: (value) => console.log("throw", value), +}); + +subject2.next(1); +subject1.next(2); +subject3.next(3); // "next" [2, 3] +subject1.next(4); // "next" [4, 3] +subject2.next(5); // "next" [4, 5] +subject1.return(); +subject3.return(); // "return" +subject2.return(); +``` + +Iterable with an empty observable + +```ts +import { all } from "@observable/all"; +import { forOf } from "@observable/for-of"; +import { pipe } from "@observable/pipe"; +import { empty } from "@observable/empty"; + +const observable1 = forOf([1, 2, 3]); +const observable2 = forOf([7, 8, 9]); +const controller = new AbortController(); + +all(new Set([observable1, empty, observable2])).subscribe({ + signal: controller.signal, + next: (value) => console.log("next", value), + return: () => console.log("return"), + throw: (value) => console.log("throw", value), +}); + +// Console output: +// "return" +``` + # AI Prompt Use the following prompt with AI assistants to help them understand this library: diff --git a/all/deno.json b/all/deno.json index e3f1987..035e0a4 100644 --- a/all/deno.json +++ b/all/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/all", - "version": "0.15.0", + "version": "0.16.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/all/mod.ts b/all/mod.ts index 1259b18..8e5a10f 100644 --- a/all/mod.ts +++ b/all/mod.ts @@ -11,7 +11,7 @@ import { takeUntil } from "@observable/take-until"; import { finalize } from "@observable/finalize"; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s {@linkcode Values|values} from _all_ of the given + * [Pushes](https://jsr.io/@observable/core#push) the latest {@linkcode Values|values} from _all_ of the given * {@linkcode observables} in [index](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#array_indices) * order. * @example @@ -83,9 +83,9 @@ export function all>( observables: Readonly<{ [Key in keyof Values]: Observable }>, ): Observable; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s an [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) - * of {@linkcode Value|values} from _all_ of the given {@linkcode observables} in [iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol) - * order. + * [Pushes](https://jsr.io/@observable/core#push) an [`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) + * of the latest {@linkcode Value|values} from _all_ of the given {@linkcode observables} in + * [iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol) order. * @example * Iterable of observables * ```ts @@ -103,6 +103,7 @@ export function all>( * return: () => console.log("return"), * throw: (value) => console.log("throw", value), * }); + * * subject2.next(1); * subject1.next(2); * subject3.next(3); // "next" [2, 3] diff --git a/async-await/README.md b/async-await/README.md index 2344325..919bbf5 100644 --- a/async-await/README.md +++ b/async-await/README.md @@ -1,8 +1,7 @@ # [@observable/async-await](https://jsr.io/@observable/async-await) [`Await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await)s the -given `expression`, [`next`](https://jsr.io/@observable/core/doc/~/Observer.next)s its resolved -value, and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. +given `expression` and [pushes](https://jsr.io/@observable/core#push) its resolved value. ## Build diff --git a/async-await/deno.json b/async-await/deno.json index 5aa19b3..6e6c289 100644 --- a/async-await/deno.json +++ b/async-await/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/async-await", - "version": "0.4.0", + "version": "0.5.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/async-await/mod.ts b/async-await/mod.ts index 217d659..f0c8114 100644 --- a/async-await/mod.ts +++ b/async-await/mod.ts @@ -2,8 +2,7 @@ import { Observable } from "@observable/core"; /** * [`Await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await)s the given - * {@linkcode expression}, [`next`](https://jsr.io/@observable/core/doc/~/Observer.next)s its resolved value, and then - * [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. + * {@linkcode expression} and [pushes](https://jsr.io/@observable/core#push) its resolved value. * @example * Resolved promise * ```ts diff --git a/at/README.md b/at/README.md index b6304d2..6e89221 100644 --- a/at/README.md +++ b/at/README.md @@ -1,8 +1,7 @@ # [@observable/at](https://jsr.io/@observable/at) -[`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s the first value at the given `index` -and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. Negative indices count -back from the last value in the sequence. +[Pushes](https://jsr.io/@observable/core#push) the first value at the given `index`. Negative +indices count back from the last value in the sequence. ## Build diff --git a/at/deno.json b/at/deno.json index 3b468d6..4bb8c3a 100644 --- a/at/deno.json +++ b/at/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/at", - "version": "0.6.0", + "version": "0.7.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/at/mod.ts b/at/mod.ts index 0a456b8..fdb7d29 100644 --- a/at/mod.ts +++ b/at/mod.ts @@ -7,9 +7,8 @@ import { empty } from "@observable/empty"; import { from } from "@observable/from"; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s the first {@linkcode Value|value} at the given - * {@linkcode index} and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. Negative - * {@linkcode index|indices} count back from the last {@linkcode Value|value} in the sequence. + * [Pushes](https://jsr.io/@observable/core#push) the first {@linkcode Value|value} at the given + * {@linkcode index}. Negative {@linkcode index|indices} count back from the last {@linkcode Value|value} in the sequence. * @example * Positive index integer * ```ts diff --git a/debounce/README.md b/debounce/README.md index f4e6357..487c07c 100644 --- a/debounce/README.md +++ b/debounce/README.md @@ -1,6 +1,6 @@ # [@observable/debounce](https://jsr.io/@observable/debounce) -Debounces each value by the given number of `milliseconds`. +Debounces each value by the given `milliseconds`. ## Build diff --git a/debounce/deno.json b/debounce/deno.json index 7da2d34..16d023a 100644 --- a/debounce/deno.json +++ b/debounce/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/debounce", - "version": "0.17.0", + "version": "0.18.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/delay/README.md b/delay/README.md index 6594cbb..65efb1c 100644 --- a/delay/README.md +++ b/delay/README.md @@ -1,6 +1,6 @@ # [@observable/delay](https://jsr.io/@observable/delay) -Delays values by the given number of `milliseconds`. +Delays values by the given `milliseconds`. ## Build diff --git a/delay/deno.json b/delay/deno.json index 28e1f01..2a62050 100644 --- a/delay/deno.json +++ b/delay/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/delay", - "version": "0.1.0", + "version": "0.2.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/delay/mod.ts b/delay/mod.ts index 798b43a..3d74a25 100644 --- a/delay/mod.ts +++ b/delay/mod.ts @@ -8,7 +8,7 @@ import { drop } from "@observable/drop"; import { from } from "@observable/from"; /** - * Delays {@linkcode Value|values} by the given number of {@linkcode milliseconds}. + * Delays {@linkcode Value|values} by the given {@linkcode milliseconds}. * @example * 1000 milliseconds * ```ts diff --git a/distinct-until-changed/README.md b/distinct-until-changed/README.md index 769e2c6..640ac4c 100644 --- a/distinct-until-changed/README.md +++ b/distinct-until-changed/README.md @@ -1,7 +1,7 @@ # [@observable/distinct-until-changed](https://jsr.io/@observable/distinct-until-changed) -Filters each value that is distinct from the previous value according to the given `comparator` -function or +[Pushes](https://jsr.io/@observable/core#push) each value that is distinct from the previous value +according to the given `comparator` function or [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) if one is not provided. diff --git a/distinct-until-changed/deno.json b/distinct-until-changed/deno.json index 89b7071..ebb0182 100644 --- a/distinct-until-changed/deno.json +++ b/distinct-until-changed/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/distinct-until-changed", - "version": "0.16.0", + "version": "0.17.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/distinct-until-changed/mod.ts b/distinct-until-changed/mod.ts index 7dd33a7..edc15c3 100644 --- a/distinct-until-changed/mod.ts +++ b/distinct-until-changed/mod.ts @@ -14,7 +14,8 @@ import { of } from "@observable/of"; const noValue = Symbol("Flag indicating that no value has been emitted yet"); /** - * Filters each {@linkcode Value|value} that is [distinct](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) + * [Pushes](https://jsr.io/@observable/core#push) each {@linkcode Value|value} that is + * [distinct](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) * from the previous {@linkcode Value|value}. * @example * ```ts @@ -40,7 +41,8 @@ const noValue = Symbol("Flag indicating that no value has been emitted yet"); */ export function distinctUntilChanged(): (source: Observable) => Observable; /** - * Filters each {@linkcode Value|value} that is distinct from the previous {@linkcode Value|value} according to the given {@linkcode comparator} function. + * [Pushes](https://jsr.io/@observable/core#push) each {@linkcode Value|value} that is distinct from the previous + * {@linkcode Value|value} according to the given {@linkcode comparator} function. * @example * ```ts * import { distinctUntilChanged } from "@observable/distinct-until-changed"; @@ -66,8 +68,10 @@ export function distinctUntilChanged( comparator: (previous: Value, current: Value) => boolean, ): (source: Observable) => Observable; /** - * Filters each {@linkcode Value|value} that is distinct from the previous {@linkcode Value|value} according to the given {@linkcode comparator} - * function or [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) if one is not provided. + * [Pushes](https://jsr.io/@observable/core#push) each {@linkcode Value|value} that is distinct from the previous + * {@linkcode Value|value} according to the given {@linkcode comparator} function or + * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) if one is + * not provided. * @example * Default comparator * ```ts diff --git a/distinct/README.md b/distinct/README.md index c8ebdc4..5ed709d 100644 --- a/distinct/README.md +++ b/distinct/README.md @@ -1,6 +1,6 @@ # [@observable/distinct](https://jsr.io/@observable/distinct) -Filters values that are +[Pushes](https://jsr.io/@observable/core#push) values that are [distinct](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) from all previous values. diff --git a/distinct/deno.json b/distinct/deno.json index 8ab61c4..3d789d3 100644 --- a/distinct/deno.json +++ b/distinct/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/distinct", - "version": "0.13.0", + "version": "0.14.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/distinct/mod.ts b/distinct/mod.ts index 8b04144..5fbf825 100644 --- a/distinct/mod.ts +++ b/distinct/mod.ts @@ -6,7 +6,8 @@ import { tap } from "@observable/tap"; import { filter } from "@observable/filter"; /** - * Filters {@linkcode Value|values} that are [distinct](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) + * [Pushes](https://jsr.io/@observable/core#push) {@linkcode Value|values} that are + * [distinct](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) * from all previous {@linkcode Value|values}. * @example * ```ts diff --git a/exhaust-map/README.md b/exhaust-map/README.md index f025efd..4a353c8 100644 --- a/exhaust-map/README.md +++ b/exhaust-map/README.md @@ -1,8 +1,9 @@ # [@observable/exhaust-map](https://jsr.io/@observable/exhaust-map) Projects each value to an [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) ignoring -any new values until the projected [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) -[`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. +any new value until all values of the projected +[`Observable`](https://jsr.io/@observable/core/doc/~/Observable) have been +[pushed](https://jsr.io/@observable/core#push). ## Build @@ -27,10 +28,9 @@ import { timeout } from "@observable/timeout"; import { map } from "@observable/map"; const controller = new AbortController(); -const observable = forOf([1, 2, 3]); pipe( - observable, + forOf([1, 2, 3]), exhaustMap((value) => pipe(timeout(100), map(() => value))), ).subscribe({ signal: controller.signal, diff --git a/exhaust-map/deno.json b/exhaust-map/deno.json index 886b1d7..0c3af9f 100644 --- a/exhaust-map/deno.json +++ b/exhaust-map/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/exhaust-map", - "version": "0.11.0", + "version": "0.12.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/exhaust-map/mod.ts b/exhaust-map/mod.ts index 439c5ba..8fc2306 100644 --- a/exhaust-map/mod.ts +++ b/exhaust-map/mod.ts @@ -7,8 +7,8 @@ import { finalize } from "@observable/finalize"; /** * {@linkcode project|Projects} each {@linkcode In|value} to an [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) ignoring any new - * {@linkcode In|values} until the {@linkcode project|projected} [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) - * [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. + * {@linkcode In|values} until all {@linkcode Out|values} of the {@linkcode project|projected} [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) + * have been [pushed](https://jsr.io/@observable/core#push). * @example * ```ts * import { exhaustMap } from "@observable/exhaust-map"; @@ -18,10 +18,9 @@ import { finalize } from "@observable/finalize"; * import { map } from "@observable/map"; * * const controller = new AbortController(); - * const observable = forOf([1, 2, 3]); * * pipe( - * observable, + * forOf([1, 2, 3]), * exhaustMap((value) => pipe(timeout(100), map(() => value))), * ).subscribe({ * signal: controller.signal, diff --git a/expand/README.md b/expand/README.md index b6ce3fd..11b1c3b 100644 --- a/expand/README.md +++ b/expand/README.md @@ -1,7 +1,7 @@ # [@observable/expand](https://jsr.io/@observable/expand) -Recursively projects each value to an -[`Observable`](https://jsr.io/@observable/core/doc/~/Observable). +Projects each value to an [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) +recursively. ## Build diff --git a/expand/deno.json b/expand/deno.json index b81a5f6..c366758 100644 --- a/expand/deno.json +++ b/expand/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/expand", - "version": "0.10.0", + "version": "0.11.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/expand/mod.ts b/expand/mod.ts index 9e15761..42eb080 100644 --- a/expand/mod.ts +++ b/expand/mod.ts @@ -7,8 +7,8 @@ import { defer } from "@observable/defer"; import { of } from "@observable/of"; /** - * Recursively {@linkcode project|projects} each {@linkcode Value|value} to an - * [`Observable`](https://jsr.io/@observable/core/doc/~/Observable). + * {@linkcode project|Projects} each {@linkcode Value|value} to an + * [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) recursively. * @example * Double until 16 * ```ts diff --git a/filter/README.md b/filter/README.md index c9fe901..c2f5318 100644 --- a/filter/README.md +++ b/filter/README.md @@ -1,6 +1,6 @@ # [@observable/filter](https://jsr.io/@observable/filter) -Filters values that satisfy the given `predicate` function. +[Pushes](https://jsr.io/@observable/core#push) values that satisfy the given `predicate` function. ## Build diff --git a/filter/deno.json b/filter/deno.json index bd8961b..e722d7a 100644 --- a/filter/deno.json +++ b/filter/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/filter", - "version": "0.11.0", + "version": "0.12.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/filter/mod.ts b/filter/mod.ts index 92f0e32..c87c680 100644 --- a/filter/mod.ts +++ b/filter/mod.ts @@ -2,7 +2,7 @@ import { isObservable, Observable } from "@observable/core"; import { from } from "@observable/from"; /** - * Filters {@linkcode Value|values} that satisfy the given {@linkcode predicate} function. + * [Pushes](https://jsr.io/@observable/core#push) {@linkcode Value|values} that satisfy the given {@linkcode predicate} function. * @example * ```ts * import { filter } from "@observable/filter"; diff --git a/flat-map/README.md b/flat-map/README.md index 70d5195..a3ae7df 100644 --- a/flat-map/README.md +++ b/flat-map/README.md @@ -1,9 +1,7 @@ # [@observable/flat-map](https://jsr.io/@observable/flat-map) -Sequentially projects each value to an -[`Observable`](https://jsr.io/@observable/core/doc/~/Observable) waiting for each projected -[`Observable`](https://jsr.io/@observable/core/doc/~/Observable) to -[`return`](https://jsr.io/@observable/core/doc/~/Observer.return) before moving on to the next. +Projects each value to an [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) +sequentially. ## Build @@ -21,35 +19,44 @@ Run `deno task test` or `deno task test:ci` to execute the unit tests via ## Example ```ts +import { Subject } from "@observable/core"; import { flatMap } from "@observable/flat-map"; import { forOf } from "@observable/for-of"; import { pipe } from "@observable/pipe"; -const observable = forOf(["a", "b", "c"]); const controller = new AbortController(); const observableLookup = { - a: forOf([1, 2, 3]), - b: forOf([4, 5, 6]), - c: forOf([7, 8, 9]), + a: new Subject(), + b: new Subject(), + c: new Subject(), } as const; -pipe(observable, flatMap((value) => observableLookup[value])).subscribe({ +pipe(forOf(["a", "b", "c"]), flatMap((value) => observableLookup[value])).subscribe({ signal: controller.signal, next: (value) => console.log("next", value), return: () => console.log("return"), throw: (value) => console.log("throw", value), }); +observableLookup.b.next(1); // ignored +observableLookup.a.next(2); +observableLookup.a.next(3); +observableLookup.a.return(); +observableLookup.c.next(4); // ignored +observableLookup.b.next(5); +observableLookup.b.next(6); +observableLookup.b.return(); +observableLookup.c.next(7); +observableLookup.c.next(8); +observableLookup.c.return(); + // Console output: -// "next" 1 // "next" 2 // "next" 3 -// "next" 4 // "next" 5 // "next" 6 // "next" 7 // "next" 8 -// "next" 9 // "return" ``` diff --git a/flat-map/deno.json b/flat-map/deno.json index 60a6d5f..ab3931f 100644 --- a/flat-map/deno.json +++ b/flat-map/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/flat-map", - "version": "0.11.0", + "version": "0.12.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/flat-map/mod.ts b/flat-map/mod.ts index ada45fb..d86def4 100644 --- a/flat-map/mod.ts +++ b/flat-map/mod.ts @@ -2,40 +2,47 @@ import { isObservable, Observable } from "@observable/core"; import { from } from "@observable/from"; /** - * Sequentially {@linkcode project|projects} each {@linkcode In|value} to an [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) - * waiting for each {@linkcode project|projected} [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) - * to [`return`](https://jsr.io/@observable/core/doc/~/Observer.return) before moving on to the next. + * {@linkcode project|Projects} each {@linkcode In|value} to an [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) sequentially. * @example * ```ts + * import { Subject } from "@observable/core"; * import { flatMap } from "@observable/flat-map"; * import { forOf } from "@observable/for-of"; * import { pipe } from "@observable/pipe"; * - * const observable = forOf(["a", "b", "c"]); * const controller = new AbortController(); * const observableLookup = { - * a: forOf([1, 2, 3]), - * b: forOf([4, 5, 6]), - * c: forOf([7, 8, 9]), + * a: new Subject(), + * b: new Subject(), + * c: new Subject(), * } as const; * - * pipe(observable, flatMap((value) => observableLookup[value])).subscribe({ + * pipe(forOf(["a", "b", "c"]), flatMap((value) => observableLookup[value])).subscribe({ * signal: controller.signal, * next: (value) => console.log("next", value), * return: () => console.log("return"), * throw: (value) => console.log("throw", value), * }); * + * observableLookup.b.next(1); // ignored + * observableLookup.a.next(2); + * observableLookup.a.next(3); + * observableLookup.a.return(); + * observableLookup.c.next(4); // ignored + * observableLookup.b.next(5); + * observableLookup.b.next(6); + * observableLookup.b.return(); + * observableLookup.c.next(7); + * observableLookup.c.next(8); + * observableLookup.c.return(); + * * // Console output: - * // "next" 1 * // "next" 2 * // "next" 3 - * // "next" 4 * // "next" 5 * // "next" 6 * // "next" 7 * // "next" 8 - * // "next" 9 * // "return" * ``` */ diff --git a/flat/README.md b/flat/README.md index 5b4ddf8..84369e5 100644 --- a/flat/README.md +++ b/flat/README.md @@ -1,7 +1,8 @@ # [@observable/flat](https://jsr.io/@observable/flat) -Sequentially mirrors each given `observables` waiting for each one to -[`return`](https://jsr.io/@observable/core/doc/~/Observer.return) before moving on to the next. +[Pushes](https://jsr.io/@observable/core#push) _all_ values from each of the given `observables` in +[iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol) +order. ## Build @@ -68,6 +69,35 @@ flat([]).subscribe({ // "return" ``` +Iterable of observables + +```ts +import { flat } from "@observable/flat"; +import { forOf } from "@observable/for-of"; +import { pipe } from "@observable/pipe"; + +const controller = new AbortController(); +const observable1 = forOf([1, 2, 3]); +const observable2 = observable1; +const observable3 = forOf([4, 5, 6]); + +flat(new Set([observable1, observable2, observable3])).subscribe({ + signal: controller.signal, + next: (value) => console.log("next", value), + return: () => console.log("return"), + throw: (value) => console.log("throw", value), +}); + +// Console output: +// "next" 1 +// "next" 2 +// "next" 3 +// "next" 4 +// "next" 5 +// "next" 6 +// "return" +``` + # AI Prompt Use the following prompt with AI assistants to help them understand this library: diff --git a/flat/deno.json b/flat/deno.json index 4066a90..fe4f9c0 100644 --- a/flat/deno.json +++ b/flat/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/flat", - "version": "0.13.0", + "version": "0.14.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/flat/mod.ts b/flat/mod.ts index cbd1992..d348c3a 100644 --- a/flat/mod.ts +++ b/flat/mod.ts @@ -5,8 +5,8 @@ import { flatMap } from "@observable/flat-map"; import { empty } from "@observable/empty"; /** - * Sequentially mirrors each given {@linkcode observables} waiting for each one to [`return`](https://jsr.io/@observable/core/doc/~/Observer.return) - * before moving on to the next. + * [Pushes](https://jsr.io/@observable/core#push) _all_ values from each of the given {@linkcode observables} in + * [index](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#array_indices) order. * @example * Array of observables * ```ts @@ -60,10 +60,9 @@ export function flat>( observables: Readonly<{ [Key in keyof Values]: Observable }>, ): Observable; /** - * Sequentially mirrors each given {@linkcode observables} waiting for each one to [`return`](https://jsr.io/@observable/core/doc/~/Observer.return) - * before moving on to the next. + * [Pushes](https://jsr.io/@observable/core#push) _all_ values from each of the given {@linkcode observables} in + * [iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol) order. * @example - * Iterable of observables * ```ts * import { flat } from "@observable/flat"; * import { forOf } from "@observable/for-of"; diff --git a/for-await-of/README.md b/for-await-of/README.md index 00cf5c7..570ddf2 100644 --- a/for-await-of/README.md +++ b/for-await-of/README.md @@ -1,9 +1,8 @@ # [@observable/for-await-of](https://jsr.io/@observable/for-await-of) -[`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s each +[Pushes](https://jsr.io/@observable/core#push) each [`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await)ed value -of the given `values` in order and then -[`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. +of the given `values` in order. ## Build diff --git a/for-await-of/deno.json b/for-await-of/deno.json index 1c024d8..8c998f6 100644 --- a/for-await-of/deno.json +++ b/for-await-of/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/for-await-of", - "version": "0.5.0", + "version": "0.6.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/for-await-of/mod.ts b/for-await-of/mod.ts index 31e69ea..2b62899 100644 --- a/for-await-of/mod.ts +++ b/for-await-of/mod.ts @@ -1,8 +1,8 @@ import { Observable } from "@observable/core"; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s each [`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await)ed - * {@linkcode Value|value} of the given {@linkcode values} in order and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. + * [Pushes](https://jsr.io/@observable/core#push) each [`await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await)ed + * {@linkcode Value|value} of the given {@linkcode values} in order. * @example * ```ts * import { forAwaitOf } from "@observable/for-await-of"; diff --git a/for-in/README.md b/for-in/README.md index 7cd7272..917bfdd 100644 --- a/for-in/README.md +++ b/for-in/README.md @@ -1,7 +1,6 @@ # [@observable/for-in](https://jsr.io/@observable/for-in) -[`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s each key of the given `object` in -order and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. +[Pushes](https://jsr.io/@observable/core#push) each key of the given `object` in order. ## Build diff --git a/for-in/deno.json b/for-in/deno.json index b7e0bfa..88be87b 100644 --- a/for-in/deno.json +++ b/for-in/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/for-in", - "version": "0.3.0", + "version": "0.4.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/for-in/mod.ts b/for-in/mod.ts index bad1e87..8451f6c 100644 --- a/for-in/mod.ts +++ b/for-in/mod.ts @@ -1,8 +1,7 @@ import { Observable } from "@observable/core"; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s each key of the given {@linkcode object} in order and then - * [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. + * [Pushes](https://jsr.io/@observable/core#push) each key of the given {@linkcode object} in order. * @example * ```ts * import { forIn } from "@observable/for-in"; diff --git a/for-of/README.md b/for-of/README.md index 19eafba..c1499c3 100644 --- a/for-of/README.md +++ b/for-of/README.md @@ -1,8 +1,8 @@ # [@observable/for-of](https://jsr.io/@observable/for-of) -[`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s each +[Pushes](https://jsr.io/@observable/core#push) each [iterated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) -value in order and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. +value in order. ## Build @@ -25,6 +25,7 @@ Populate array import { forOf } from "@observable/for-of"; const controller = new AbortController(); + forOf([1, 2, 3]).subscribe({ signal: controller.signal, next: (value) => console.log("next", value), @@ -45,6 +46,7 @@ Empty array import { forOf } from "@observable/for-of"; const controller = new AbortController(); + forOf([]).subscribe({ signal: controller.signal, next: (value) => console.log("next", value), @@ -62,6 +64,7 @@ Iterable import { forOf } from "@observable/for-of"; const controller = new AbortController(); + forOf(new Set([1, 2, 1, 2, 3, 3])).subscribe({ signal: controller.signal, next: (value) => console.log("next", value), diff --git a/for-of/deno.json b/for-of/deno.json index f9ebf5e..2c78c30 100644 --- a/for-of/deno.json +++ b/for-of/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/for-of", - "version": "0.5.0", + "version": "0.6.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/for-of/mod.ts b/for-of/mod.ts index e6d1507..b2afa2a 100644 --- a/for-of/mod.ts +++ b/for-of/mod.ts @@ -2,14 +2,15 @@ import { Observable } from "@observable/core"; import { empty } from "@observable/empty"; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s each [iterated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) - * value in order and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. + * [Pushes](https://jsr.io/@observable/core#push) each [iterated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) + * value in order. * @example * Populate array * ```ts * import { forOf } from "@observable/for-of"; * * const controller = new AbortController(); + * * forOf([1, 2, 3]).subscribe({ * signal: controller.signal, * next: (value) => console.log("next", value), @@ -29,6 +30,7 @@ import { empty } from "@observable/empty"; * import { forOf } from "@observable/for-of"; * * const controller = new AbortController(); + * * forOf([]).subscribe({ * signal: controller.signal, * next: (value) => console.log("next", value), @@ -44,13 +46,14 @@ export function forOf>( values: Values, ): Observable; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s each [iterated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) - * {@linkcode Value|value} in order and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. + * [Pushes](https://jsr.io/@observable/core#push) each [iterated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) + * {@linkcode Value|value} in order. * @example * ```ts * import { forOf } from "@observable/for-of"; * * const controller = new AbortController(); + * * forOf(new Set([1, 2, 1, 2, 3, 3])).subscribe({ * signal: controller.signal, * next: (value) => console.log("next", value), diff --git a/interval/README.md b/interval/README.md index 7bc67ca..9b5ebc1 100644 --- a/interval/README.md +++ b/interval/README.md @@ -1,7 +1,7 @@ # [@observable/interval](https://jsr.io/@observable/interval) -Repeatedly [`next`](https://jsr.io/@observable/core/doc/~/Observer.next)s a `void` value with a -fixed time delay between each call. +Repeatedly [pushes](https://jsr.io/@observable/core#push) a `void` value at an interval of the given +`milliseconds`. ## Build diff --git a/interval/deno.json b/interval/deno.json index 1e45c9d..eda4ebd 100644 --- a/interval/deno.json +++ b/interval/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/interval", - "version": "0.12.0", + "version": "0.13.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/interval/mod.ts b/interval/mod.ts index d49fa11..8d64592 100644 --- a/interval/mod.ts +++ b/interval/mod.ts @@ -10,8 +10,7 @@ import { never } from "@observable/never"; const infiniteVoid = defer(() => forOf(generateInfiniteVoid())); /** - * Repeatedly [`next`](https://jsr.io/@observable/core/doc/~/Observer.next)s a `void` value with a - * fixed {@linkcode milliseconds|time delay} between each call. + * Repeatedly [pushes](https://jsr.io/@observable/core#push) a `void` value at an interval of the given {@linkcode milliseconds}. * @example * Positive integer milliseconds * ```ts diff --git a/last-value-from/README.md b/last-value-from/README.md index 86ce098..51c7dca 100644 --- a/last-value-from/README.md +++ b/last-value-from/README.md @@ -1,8 +1,7 @@ # [@observable/last-value-from](https://jsr.io/@observable/last-value-from) [`Resolve`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)s -with the last value of the given `observable` on -[`return`](https://jsr.io/@observable/core/doc/~/Observer.return), +with the last value of the given `observable`, [`reject`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)s with a [`throw`](https://jsr.io/@observable/core/doc/~/Observer.throw)n value of the given `observable`, or @@ -10,7 +9,7 @@ with a [`throw`](https://jsr.io/@observable/core/doc/~/Observer.throw)n value of with a [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) if the given `observable` [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s without -[`next`](https://jsr.io/@observable/core/doc/~/Observer.next)ing a value. +[pushing](https://jsr.io/@observable/core#push) a value. ## Build diff --git a/last-value-from/deno.json b/last-value-from/deno.json index f33cb54..5a91129 100644 --- a/last-value-from/deno.json +++ b/last-value-from/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/last-value-from", - "version": "0.8.0", + "version": "0.9.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/last-value-from/mod.ts b/last-value-from/mod.ts index 1b78be2..c245c74 100644 --- a/last-value-from/mod.ts +++ b/last-value-from/mod.ts @@ -4,13 +4,13 @@ import { at } from "@observable/at"; /** * [`Resolve`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve)s with the - * last {@linkcode Value|value} of the given {@linkcode observable} on [`return`](https://jsr.io/@observable/core/doc/~/Observer.return), + * last {@linkcode Value|value} of the given {@linkcode observable}, * [`reject`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)s with * a [`throw`](https://jsr.io/@observable/core/doc/~/Observer.throw)n value of the given {@linkcode observable}, or * [`reject`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject)s with a * [`TypeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError) * if the given {@linkcode observable} [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s - * without [`next`](https://jsr.io/@observable/core/doc/~/Observer.next)ing a {@linkcode Value|value}. + * without [pushing](https://jsr.io/@observable/core#push) a {@linkcode Value|value}. * @example * Last emitted value * ```ts diff --git a/materialize/README.md b/materialize/README.md index 61f9c1a..e90ad29 100644 --- a/materialize/README.md +++ b/materialize/README.md @@ -1,7 +1,9 @@ # [@observable/materialize](https://jsr.io/@observable/materialize) -[`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s all -[notifications](https://jsr.io/@observable/core#notification) as values. +[Pushes](https://jsr.io/@observable/core#push) all +[notifications](https://jsr.io/@observable/core#notification) as values marked with their original +types within +[`ObserverNotification`](https://jsr.io/@observable/materialize/doc/~/ObserverNotification) objects. ## Build diff --git a/materialize/deno.json b/materialize/deno.json index fa4a906..bf0c69c 100644 --- a/materialize/deno.json +++ b/materialize/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/materialize", - "version": "0.12.0", + "version": "0.13.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/materialize/mod.test.ts b/materialize/mod.test.ts index 2946e6c..26a759d 100644 --- a/materialize/mod.test.ts +++ b/materialize/mod.test.ts @@ -1,9 +1,9 @@ -import { assertEquals } from "@std/assert"; +import { assertEquals, assertStrictEquals, assertThrows } from "@std/assert"; import { Observer } from "@observable/core"; import { forOf } from "@observable/for-of"; import { pipe } from "@observable/pipe"; import { throwError } from "@observable/throw-error"; -import { materialize, type ObserverNotification } from "./mod.ts"; +import { isObserverNotification, materialize, type ObserverNotification } from "./mod.ts"; Deno.test( "materialize should emit the notifications from a source observable that returns", @@ -90,3 +90,95 @@ Deno.test("materialize should honor unsubscription", () => { assertEquals(returnCalls, []); assertEquals(throwCalls, []); }); + +Deno.test("isObserverNotification should throw if no arguments are provided", () => { + assertThrows( + // @ts-expect-error: Testing invalid arguments + () => isObserverNotification(), + TypeError, + "1 argument required but 0 present", + ); +}); + +Deno.test("isObserverNotification should return true for a next notification", () => { + // Arrange + const notification: ObserverNotification = ["next", 0]; + + // Act + const result = isObserverNotification(notification); + + // Assert + assertStrictEquals(result, true); +}); + +Deno.test("isObserverNotification should return true for a return notification", () => { + // Arrange + const notification: ObserverNotification = ["return"]; + + // Act + const result = isObserverNotification(notification); + + // Assert + assertStrictEquals(result, true); +}); + +Deno.test("isObserverNotification should return true for a throw notification", () => { + // Arrange + const error = new Error("test"); + const notification: ObserverNotification = ["throw", error]; + + // Act + const result = isObserverNotification(notification); + + // Assert + assertStrictEquals(result, true); +}); + +Deno.test( + "isObserverNotification should return false when next lacks a value", + () => { + // Arrange + const notification = ["next"]; + + // Act + const result = isObserverNotification(notification); + + // Assert + assertStrictEquals(result, false); + }, +); +Deno.test( + "isObserverNotification should return false when throw lacks a value", + () => { + // Arrange + const notification = ["throw"]; + + // Act + const result = isObserverNotification(notification); + + // Assert + assertStrictEquals(result, false); + }, +); + +Deno.test("isObserverNotification should return false for an unknown notification kind", () => { + // Arrange + const notification = ["invalid"]; + + // Act + const result = isObserverNotification(notification); + + // Assert + assertStrictEquals(result, false); +}); + +Deno.test("isObserverNotification should return false when the value is not an array", () => { + // Arrange + const value = null; + + // Act + const result = isObserverNotification(value); + + // Assert + assertStrictEquals(result, false); +}); diff --git a/materialize/mod.ts b/materialize/mod.ts index 6d99fde..2a40fbd 100644 --- a/materialize/mod.ts +++ b/materialize/mod.ts @@ -12,7 +12,8 @@ export type ObserverNotification = Readonly< >; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s all [notifications](https://jsr.io/@observable/core#notification) as values. + * [Pushes](https://jsr.io/@observable/core#push) all [notifications](https://jsr.io/@observable/core#notification) + * as values marked with their original types within {@linkcode ObserverNotification} objects. * @example * Notifications as values * ```ts @@ -117,3 +118,66 @@ export function materialize(): ( ); }; } + +/** + * Checks if a {@linkcode value} is an object that implements the {@linkcode ObserverNotification} interface. + * @example + * Next + * ```ts + * import { isObserverNotification, ObserverNotification } from "@observable/materialize"; + * + * const value: ObserverNotification = ["next", 1]; + * + * isObserverNotification(value); // true + * ``` + * @example + * Return + * ```ts + * import { isObserverNotification, ObserverNotification } from "@observable/materialize"; + * + * const value: ObserverNotification = ["return"]; + * + * isObserverNotification(value); // true + * ``` + * @example + * Throw + * ```ts + * import { isObserverNotification, ObserverNotification } from "@observable/materialize"; + * + * const value: ObserverNotification = ["throw", new Error("error")]; + * + * isObserverNotification(value); // true + * ``` + * @example + * Invalid Next + * ```ts + * import { isObserverNotification, ObserverNotification } from "@observable/materialize"; + * + * const value: ObserverNotification = ["next"]; + * + * isObserverNotification(value); // false + * ``` + * @example + * Invalid Throw + * ```ts + * import { isObserverNotification, ObserverNotification } from "@observable/materialize"; + * + * const value: ObserverNotification = ["throw"]; + * + * isObserverNotification(value); // false + * ``` + * @example + * Invalid + * ```ts + * import { isObserverNotification, ObserverNotification } from "@observable/materialize"; + * + * const value = ["invalid"]; + * + * isObserverNotification(value); // false + * ``` + */ +export function isObserverNotification(value: unknown): value is ObserverNotification { + if (!arguments.length) throw new TypeError("1 argument required but 0 present"); + return Array.isArray(value) && + (value[0] === "return" || ((value[0] === "next" || value[0] === "throw") && value.length > 1)); +} diff --git a/merge-map/README.md b/merge-map/README.md index 59c3a09..2dd48ca 100644 --- a/merge-map/README.md +++ b/merge-map/README.md @@ -1,7 +1,7 @@ # [@observable/merge-map](https://jsr.io/@observable/merge-map) -Concurrently projects each value to an -[`Observable`](https://jsr.io/@observable/core/doc/~/Observable). +Projects each value to an [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) +concurrently. ## Build @@ -19,26 +19,37 @@ Run `deno task test` or `deno task test:ci` to execute the unit tests via ## Example ```ts +import { Subject } from "@observable/core"; import { mergeMap } from "@observable/merge-map"; import { forOf } from "@observable/for-of"; import { pipe } from "@observable/pipe"; const controller = new AbortController(); const observableLookup = { - 1: forOf([1, 2, 3]), - 2: forOf([4, 5, 6]), - 3: forOf([7, 8, 9]), + a: new Subject(), + b: new Subject(), + c: new Subject(), } as const; -pipe( - forOf([1, 2, 3]), - mergeMap((value) => observableLookup[value]), -).subscribe({ + +pipe(forOf(["a", "b", "c"]), mergeMap((value) => observableLookup[value])).subscribe({ signal: controller.signal, next: (value) => console.log("next", value), return: () => console.log("return"), throw: (value) => console.log("throw", value), }); +observableLookup.b.next(1); +observableLookup.a.next(2); +observableLookup.a.next(3); +observableLookup.a.return(); +observableLookup.c.next(4); +observableLookup.b.next(5); +observableLookup.b.next(6); +observableLookup.b.return(); +observableLookup.c.next(7); +observableLookup.c.next(8); +observableLookup.c.return(); + // Console output: // "next" 1 // "next" 2 @@ -48,7 +59,6 @@ pipe( // "next" 6 // "next" 7 // "next" 8 -// "next" 9 // "return" ``` diff --git a/merge-map/deno.json b/merge-map/deno.json index f76da9c..e991396 100644 --- a/merge-map/deno.json +++ b/merge-map/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/merge-map", - "version": "0.14.0", + "version": "0.15.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/merge-map/mod.ts b/merge-map/mod.ts index e8de3ed..53529a3 100644 --- a/merge-map/mod.ts +++ b/merge-map/mod.ts @@ -2,27 +2,40 @@ import { isObservable, Observable } from "@observable/core"; import { from } from "@observable/from"; /** - * Concurrently {@linkcode project|projects} each {@linkcode In|value} to an - * [`Observable`](https://jsr.io/@observable/core/doc/~/Observable). + * {@linkcode project|Projects} each {@linkcode In|value} to an [`Observable`](https://jsr.io/@observable/core/doc/~/Observable) concurrently. * @example * ```ts + * import { Subject } from "@observable/core"; * import { mergeMap } from "@observable/merge-map"; * import { forOf } from "@observable/for-of"; * import { pipe } from "@observable/pipe"; * * const controller = new AbortController(); * const observableLookup = { - * 1: forOf([1, 2, 3]), - * 2: forOf([4, 5, 6]), - * 3: forOf([7, 8, 9]), + * a: new Subject(), + * b: new Subject(), + * c: new Subject(), * } as const; - * pipe(forOf([1, 2, 3]), mergeMap((value) => observableLookup[value])).subscribe({ + * + * pipe(forOf(["a", "b", "c"]), mergeMap((value) => observableLookup[value])).subscribe({ * signal: controller.signal, * next: (value) => console.log("next", value), * return: () => console.log("return"), * throw: (value) => console.log("throw", value), * }); * + * observableLookup.b.next(1); + * observableLookup.a.next(2); + * observableLookup.a.next(3); + * observableLookup.a.return(); + * observableLookup.c.next(4); + * observableLookup.b.next(5); + * observableLookup.b.next(6); + * observableLookup.b.return(); + * observableLookup.c.next(7); + * observableLookup.c.next(8); + * observableLookup.c.return(); + * * // Console output: * // "next" 1 * // "next" 2 @@ -32,7 +45,6 @@ import { from } from "@observable/from"; * // "next" 6 * // "next" 7 * // "next" 8 - * // "next" 9 * // "return" * ``` */ diff --git a/merge/README.md b/merge/README.md index 516f4f5..72e9c59 100644 --- a/merge/README.md +++ b/merge/README.md @@ -1,6 +1,6 @@ # [@observable/merge](https://jsr.io/@observable/merge) -Concurrently mirrors all of the given `observables` +[Pushes](https://jsr.io/@observable/core#push) each value of the given `observables`. ## Build diff --git a/merge/deno.json b/merge/deno.json index 9445fa4..af63c19 100644 --- a/merge/deno.json +++ b/merge/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/merge", - "version": "0.13.0", + "version": "0.14.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/merge/mod.ts b/merge/mod.ts index a596025..106584d 100644 --- a/merge/mod.ts +++ b/merge/mod.ts @@ -5,7 +5,7 @@ import { mergeMap } from "@observable/merge-map"; import { empty } from "@observable/empty"; /** - * Concurrently mirrors all of the given {@linkcode observables}. + * [Pushes](https://jsr.io/@observable/core#push) each value of the given {@linkcode observables}. * @example * Array of observables * ```ts @@ -54,8 +54,7 @@ export function merge>( observables: Readonly<{ [Key in keyof Values]: Observable }>, ): Observable; /** - * Concurrently [`next`](https://jsr.io/@observable/core/doc/~/Observer.next)s all values from all - * given {@linkcode observables}. + * [Pushes](https://jsr.io/@observable/core#push) each {@linkcode Value|value} of the given {@linkcode observables}. * @example * Iterable of observables * ```ts diff --git a/of/README.md b/of/README.md index 988b34a..3673a45 100644 --- a/of/README.md +++ b/of/README.md @@ -1,7 +1,6 @@ # [@observable/of](https://jsr.io/@observable/of) -[`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s the given `value` and then -[`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. +[Pushes](https://jsr.io/@observable/core#push) the given `value`. ## Build diff --git a/of/deno.json b/of/deno.json index 533da22..70b1cd3 100644 --- a/of/deno.json +++ b/of/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/of", - "version": "0.11.0", + "version": "0.12.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/of/mod.ts b/of/mod.ts index 774f60c..bb8dc10 100644 --- a/of/mod.ts +++ b/of/mod.ts @@ -2,8 +2,7 @@ import type { Observable } from "@observable/core"; import { forOf } from "@observable/for-of"; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s the given {@linkcode value} - * and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. + * [Pushes](https://jsr.io/@observable/core#push) the given {@linkcode value}. * @example * ```ts * import { of } from "@observable/of"; diff --git a/pairwise/README.md b/pairwise/README.md index 45f8796..319f1bd 100644 --- a/pairwise/README.md +++ b/pairwise/README.md @@ -1,6 +1,6 @@ # [@observable/pairwise](https://jsr.io/@observable/pairwise) -[`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s +[Pushes](https://jsr.io/@observable/core#push) [`pair`](https://jsr.io/@observable/pairwise/doc/~/Pair)s of consecutive values. ## Build diff --git a/pairwise/deno.json b/pairwise/deno.json index 234e222..615245b 100644 --- a/pairwise/deno.json +++ b/pairwise/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/pairwise", - "version": "0.14.0", + "version": "0.15.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/pairwise/mod.ts b/pairwise/mod.ts index 2eb6e0a..2b17c43 100644 --- a/pairwise/mod.ts +++ b/pairwise/mod.ts @@ -15,7 +15,7 @@ const noValue = Symbol("Flag indicating that no value has been emitted yet"); export type Pair = Readonly<[previous: Value, current: Value]>; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s {@linkcode Pair|pair}s of consecutive {@linkcode Value|values}. + * [Pushes](https://jsr.io/@observable/core#push) {@linkcode Pair|pairs} of consecutive {@linkcode Value|values}. * @example * ```ts * import { pairwise } from "@observable/pairwise"; diff --git a/race/README.md b/race/README.md index 7c3c851..661f9c4 100644 --- a/race/README.md +++ b/race/README.md @@ -1,8 +1,7 @@ # [@observable/race](https://jsr.io/@observable/race) -Mirrors the first of the given `observables` to -[`next`](https://jsr.io/@observable/core/doc/~/Observer.next) or -[`throw`](https://jsr.io/@observable/core/doc/~/Observer.throw) a value. +[Pushes](https://jsr.io/@observable/core#push) values from the first of the given `observables` to +[push](https://jsr.io/@observable/core#push) a value. ## Build diff --git a/race/deno.json b/race/deno.json index e9efbe9..7cf039c 100644 --- a/race/deno.json +++ b/race/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/race", - "version": "0.15.0", + "version": "0.16.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/race/mod.ts b/race/mod.ts index 8d9c36d..6f4f9f1 100644 --- a/race/mod.ts +++ b/race/mod.ts @@ -9,9 +9,7 @@ import { filter } from "@observable/filter"; import { empty } from "@observable/empty"; /** - * Mirrors the first of the given {@linkcode observables} to - * [`next`](https://jsr.io/@observable/core/doc/~/Observer.next) or - * [`throw`](https://jsr.io/@observable/core/doc/~/Observer.throw) a value. + * [Pushes](https://jsr.io/@observable/core#push) values from the first of the given {@linkcode observables} to [push](https://jsr.io/@observable/core#push) a value. * @example * Array of observables * ```ts @@ -59,9 +57,7 @@ export function race>( observables: Readonly<{ [Key in keyof Values]: Observable }>, ): Observable; /** - * Mirrors the first of the given {@linkcode observables} to - * [`next`](https://jsr.io/@observable/core/doc/~/Observer.next) or - * [`throw`](https://jsr.io/@observable/core/doc/~/Observer.throw) a value. + * [Pushes](https://jsr.io/@observable/core#push) values from the first of the given {@linkcode observables} to [push](https://jsr.io/@observable/core#push) a value. * @example * Iterable of observables * ```ts diff --git a/reduce/README.md b/reduce/README.md index e3b4cc1..410d177 100644 --- a/reduce/README.md +++ b/reduce/README.md @@ -1,7 +1,6 @@ # [@observable/reduce](https://jsr.io/@observable/reduce) -Reduces each value to a single value on -[`return`](https://jsr.io/@observable/core/doc/~/Observer.return). +Reduces all values to a single values. ## Build diff --git a/reduce/deno.json b/reduce/deno.json index 60e2c8d..8008cba 100644 --- a/reduce/deno.json +++ b/reduce/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/reduce", - "version": "0.11.0", + "version": "0.12.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/reduce/mod.ts b/reduce/mod.ts index 217d6d9..3c5fe95 100644 --- a/reduce/mod.ts +++ b/reduce/mod.ts @@ -4,8 +4,7 @@ import { pipe } from "@observable/pipe"; import { at } from "@observable/at"; /** - * {@linkcode reducer|Reduces} each {@linkcode In|value} to a single {@linkcode Out|value} on - * [`return`](https://jsr.io/@observable/core/doc/~/Observer.return). + * {@linkcode reducer|Reduces} all {@linkcode In|values} to a single {@linkcode Out|value}. * @example * ```ts * import { reduce } from "@observable/reduce"; diff --git a/repeat/README.md b/repeat/README.md index c86db50..4c22dc5 100644 --- a/repeat/README.md +++ b/repeat/README.md @@ -2,7 +2,7 @@ Re-[`subscribe`](https://jsr.io/@observable/core/doc/~/Observable.subscribe)s on [`return`](https://jsr.io/@observable/core/doc/~/Observer.return) as long as the given `notifier` -then [`next`](https://jsr.io/@observable/core/doc/~/Observer.next)s a value. +then [pushes](https://jsr.io/@observable/core#push) a value. ## Build diff --git a/repeat/deno.json b/repeat/deno.json index 167ba49..8252cbf 100644 --- a/repeat/deno.json +++ b/repeat/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/repeat", - "version": "0.13.0", + "version": "0.14.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/repeat/mod.ts b/repeat/mod.ts index 61eac51..f5dbc80 100644 --- a/repeat/mod.ts +++ b/repeat/mod.ts @@ -9,7 +9,7 @@ import { of } from "@observable/of"; /** * Re-[`subscribe`](https://jsr.io/@observable/core/doc/~/Observable.subscribe)s on * [`return`](https://jsr.io/@observable/core/doc/~/Observer.return) as long as the given {@linkcode notifier} - * then [`next`](https://jsr.io/@observable/core/doc/~/Observer.next)s a value. + * then [pushes](https://jsr.io/@observable/core#push) a value. * @example * ```ts * import { repeat } from "@observable/repeat"; diff --git a/scan/README.md b/scan/README.md index 54c981e..0d13ca1 100644 --- a/scan/README.md +++ b/scan/README.md @@ -1,6 +1,6 @@ # [@observable/scan](https://jsr.io/@observable/scan) -Reduces each value to a single value. +Reduces each value to an intermediate value. ## Build diff --git a/scan/deno.json b/scan/deno.json index a1e81da..9ffd358 100644 --- a/scan/deno.json +++ b/scan/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/scan", - "version": "0.10.0", + "version": "0.11.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/scan/mod.ts b/scan/mod.ts index ed11608..a1208c8 100644 --- a/scan/mod.ts +++ b/scan/mod.ts @@ -5,7 +5,7 @@ import { pipe } from "@observable/pipe"; import { map } from "@observable/map"; /** - * {@linkcode reducer|Reduces} each {@linkcode In|value} to a single {@linkcode Out|value}. + * {@linkcode reducer|Reduces} each {@linkcode In|value} to an intermediate {@linkcode Out|value}. * @example * ```ts * import { scan } from "@observable/scan"; diff --git a/take-until/README.md b/take-until/README.md index 2957ed8..bdafde6 100644 --- a/take-until/README.md +++ b/take-until/README.md @@ -1,7 +1,7 @@ # [@observable/take-until](https://jsr.io/@observable/take-until) -Takes values until the given `notifier` -[`next`](https://jsr.io/@observable/core/doc/~/Observer.next)s a value. +[Pushes](https://jsr.io/@observable/core#push) values until the given `notifier` also +[pushes](https://jsr.io/@observable/core#push) a value. ## Build diff --git a/take-until/deno.json b/take-until/deno.json index 8335ee9..557b8a0 100644 --- a/take-until/deno.json +++ b/take-until/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/take-until", - "version": "0.12.0", + "version": "0.13.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/take-until/mod.ts b/take-until/mod.ts index 5fb355b..8110df1 100644 --- a/take-until/mod.ts +++ b/take-until/mod.ts @@ -2,8 +2,8 @@ import { isObservable, Observable } from "@observable/core"; import { from } from "@observable/from"; /** - * Takes {@linkcode Value|values} until the given {@linkcode notifier} - * [`next`](https://jsr.io/@observable/core/doc/~/Observer.next)s a value. + * [Pushes](https://jsr.io/@observable/core#push) {@linkcode Value|values} until the given {@linkcode notifier} + * also [pushes](https://jsr.io/@observable/core#push) a value. * @example * ```ts * import { Subject } from "@observable/core"; diff --git a/take/README.md b/take/README.md index c96d562..f2fd7a9 100644 --- a/take/README.md +++ b/take/README.md @@ -1,7 +1,6 @@ # [@observable/take](https://jsr.io/@observable/take) -Takes the first `count` of values and then -[`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. +[Pushes](https://jsr.io/@observable/core#push) the first of the given `count` of values. ## Build diff --git a/take/deno.json b/take/deno.json index 1422763..31bd33e 100644 --- a/take/deno.json +++ b/take/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/take", - "version": "0.14.0", + "version": "0.15.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/take/mod.ts b/take/mod.ts index cda505a..f62b2eb 100644 --- a/take/mod.ts +++ b/take/mod.ts @@ -3,7 +3,7 @@ import { from } from "@observable/from"; import { empty } from "@observable/empty"; /** - * Takes the first {@linkcode count} of {@linkcode Value|values} and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. + * [Pushes](https://jsr.io/@observable/core#push) the first of the given {@linkcode count} of {@linkcode Value|values}. * @example * Positive integer count * ```ts diff --git a/throttle/README.md b/throttle/README.md index 9f033e9..b9b1271 100644 --- a/throttle/README.md +++ b/throttle/README.md @@ -1,6 +1,6 @@ # [@observable/throttle](https://jsr.io/@observable/throttle) -Throttles each value by the given number of `milliseconds`. +Throttles each value by the given `milliseconds`. ## Build diff --git a/throttle/deno.json b/throttle/deno.json index a22a121..fad5715 100644 --- a/throttle/deno.json +++ b/throttle/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/throttle", - "version": "0.17.0", + "version": "0.18.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/timeout/README.md b/timeout/README.md index 86db5e6..01c0b6e 100644 --- a/timeout/README.md +++ b/timeout/README.md @@ -1,7 +1,6 @@ # [@observable/timeout](https://jsr.io/@observable/timeout) -[`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s a `void` value after the given number -of `milliseconds` and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. +[Pushes](https://jsr.io/@observable/core#push) a `void` value after the given `milliseconds`. ## Build diff --git a/timeout/deno.json b/timeout/deno.json index 3ad9c41..a848555 100644 --- a/timeout/deno.json +++ b/timeout/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/timeout", - "version": "0.12.0", + "version": "0.13.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/timeout/mod.ts b/timeout/mod.ts index 9cf7a58..b40bf95 100644 --- a/timeout/mod.ts +++ b/timeout/mod.ts @@ -6,8 +6,7 @@ import { pipe } from "@observable/pipe"; import { take } from "@observable/take"; /** - * [`Next`](https://jsr.io/@observable/core/doc/~/Observer.next)s a `void` value after the given number of - * {@linkcode milliseconds} and then [`return`](https://jsr.io/@observable/core/doc/~/Observer.return)s. + * [Pushes](https://jsr.io/@observable/core#push) a `void` value after the given {@linkcode milliseconds}. * @example * Positive integer milliseconds * ```ts