diff --git a/all/deno.json b/all/deno.json index e5b98b7..f041f64 100644 --- a/all/deno.json +++ b/all/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/all", - "version": "0.21.0", + "version": "0.22.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/all/mod.test.ts b/all/mod.test.ts index 11692db..4da836b 100644 --- a/all/mod.test.ts +++ b/all/mod.test.ts @@ -135,14 +135,14 @@ Deno.test("all should return empty when given an empty set", () => { Deno.test("all should be empty when given an empty iterable", () => { // Arrange const notifications: Array>> = []; - const iterable: Iterable> = { + const observables: Iterable = { [Symbol.iterator]: () => ({ next: () => ({ done: true, value: undefined }), return: () => ({ done: true, value: undefined }), throw: () => ({ done: true, value: undefined }), }), }; - const observable = all(iterable); + const observable = all(observables); // Act pipe(observable, materialize()).subscribe( diff --git a/all/mod.ts b/all/mod.ts index 1c25f67..bfbe140 100644 --- a/all/mod.ts +++ b/all/mod.ts @@ -139,23 +139,23 @@ export function all( observables: Iterable>, ): Observable>; export function all( - iterable: Iterable>, + observables: Iterable>, ): Observable> { if (!arguments.length) throw new TypeError("1 argument required but 0 present"); - if (!isIterable(iterable)) throw new TypeError("Parameter 1 is not of type 'Iterable'"); + if (!isIterable(observables)) throw new TypeError("Parameter 1 is not of type 'Iterable'"); - if (Array.isArray(iterable) && !iterable.length) return empty; - if (iterable instanceof Set && !iterable.size) return empty; + if (Array.isArray(observables) && !observables.length) return empty; + if (observables instanceof Set && !observables.size) return empty; // We could compose a few different operators to achieve the same result, but this is // a more direct implementation that is easier to understand and reason about. return new Observable((observer) => { /** - * The bounded {@linkcode iterable} which has a known `size` for subsequent logic. + * The bounded {@linkcode observables} which has a known `size` for subsequent logic. */ - const observables = bound(iterable); + const boundObservables = bound(observables); - if (!observables.size) return observer.return(); + if (!boundObservables.size) return observer.return(); /** * Tracking the number of first values that have been received. @@ -164,7 +164,7 @@ export function all( /** * Tracking the number of active inner subscriptions. */ - let activeInnerSubscriptions = observables.size; + let activeInnerSubscriptions = boundObservables.size; /** * Tracking a known list of {@linkcode buffer|buffered} values, so we don't have to clone them while nexting to prevent reentrant behaviors. @@ -180,7 +180,7 @@ export function all( */ let index = 0; - for (const observable of observables) { + for (const observable of boundObservables) { /** * Tracking if the {@linkcode observable} has pushed its first value. */ @@ -202,7 +202,7 @@ export function all( snapshot = undefined; } - if (receivedFirstValueCount === observables.size) { + if (receivedFirstValueCount === boundObservables.size) { observer.next(snapshot ??= Object.freeze(buffer.slice())); } }, diff --git a/for-of/deno.json b/for-of/deno.json index 0c1f2f5..5eed684 100644 --- a/for-of/deno.json +++ b/for-of/deno.json @@ -1,6 +1,6 @@ { "name": "@observable/for-of", - "version": "0.9.0", + "version": "0.10.0", "license": "MIT", "exports": "./mod.ts", "publish": { "exclude": ["*.test.ts"] } diff --git a/for-of/mod.ts b/for-of/mod.ts index b2afa2a..e6c591e 100644 --- a/for-of/mod.ts +++ b/for-of/mod.ts @@ -68,13 +68,13 @@ export function forOf>( * // "return" * ``` */ -export function forOf(iterable: Iterable): Observable; -export function forOf(iterable: Iterable): Observable { +export function forOf(values: Iterable): Observable; +export function forOf(values: Iterable): Observable { if (!arguments.length) throw new TypeError("1 argument required but 0 present"); - if (!isIterable(iterable)) throw new TypeError("Parameter 1 is not of type 'Iterable'"); - if (Array.isArray(iterable) && !iterable.length) return empty; + if (!isIterable(values)) throw new TypeError("Parameter 1 is not of type 'Iterable'"); + if (Array.isArray(values) && !values.length) return empty; return new Observable((observer) => { - for (const value of iterable) { + for (const value of values) { observer.next(value); if (observer.signal.aborted) return; }