From 6b80df17ce5a19ad19690c691ce00b79768f6ea7 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 10 Sep 2023 16:39:30 -0700 Subject: [PATCH] fix: update import path for `Collection` type definition and use generics Ref: https://github.com/stdlib-js/stdlib/commit/bde4671201dfa6b510f88bcb60d455f44c0842e1 --- .../async/some-by-right/docs/types/index.d.ts | 33 ++++++++----------- .../async/some-by-right/docs/types/test.ts | 4 +-- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/async/some-by-right/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/async/some-by-right/docs/types/index.d.ts index 917545343ff..2653fcd7328 100644 --- a/lib/node_modules/@stdlib/utils/async/some-by-right/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/async/some-by-right/docs/types/index.d.ts @@ -20,26 +20,26 @@ /// -import { Collection } from '@stdlib/types/object'; +import { Collection } from '@stdlib/types/array'; /** * Interface defining function options. */ -interface Options { +interface Options { /** * The maximum number of pending invocations at any one time. */ limit?: number; /** - * Boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection (default: false). + * Boolean indicating whether to sequentially invoke the `predicate` function for each `collection` element. If `true`, the function sets `options.limit=1`. */ series?: boolean; /** * Execution context. */ - thisArg?: any; + thisArg?: ThisParameterType>; } /** @@ -76,7 +76,7 @@ type Callback = Nullary | Unary | Binary; * @param value - collection value * @param next - callback which should be called once the predicate function has finished processing a collection value */ -type BinaryPredicate = ( value: any, next: Callback ) => void; +type BinaryPredicate = ( this: V, value: T, next: Callback ) => void; /** * Checks whether an element in a collection passes a test. @@ -85,7 +85,7 @@ type BinaryPredicate = ( value: any, next: Callback ) => void; * @param index - collection index * @param next - callback which should be called once the `predicate` function has finished processing a collection `value` */ -type TernaryPredicate = ( value: any, index: number, next: Callback ) => void; +type TernaryPredicate = ( this: V, value: T, index: number, next: Callback ) => void; /** * Checks whether an element in a collection passes a test. @@ -95,7 +95,7 @@ type TernaryPredicate = ( value: any, index: number, next: Callback ) => void; * @param collection - input collection * @param next - callback which should be called once the `predicate` function has finished processing a collection `value` */ -type QuaternaryPredicate = ( value: any, index: number, collection: Collection, next: Callback ) => void; // tslint-disable-line max-line-length +type QuaternaryPredicate = ( this: V, value: T, index: number, collection: Collection, next: Callback ) => void; /** * Checks whether an element in a collection passes a test. @@ -105,16 +105,16 @@ type QuaternaryPredicate = ( value: any, index: number, collection: Collection, * @param collection - input collection * @param next - callback which should be called once the `predicate` function has finished processing a collection `value` */ -type Predicate = BinaryPredicate | TernaryPredicate | QuaternaryPredicate; +type Predicate = BinaryPredicate | TernaryPredicate | QuaternaryPredicate; /** -* Tests whether at least one element in a collection passes a test implemented by a predicate function. +* Tests whether at least `n` elements in a collection pass a test implemented by a predicate function. * * @param collection - input collection * @param n - number of elements * @param done - function to invoke upon completion */ -type FactoryFunction = ( collection: Collection, n: number, done: Callback ) => void; // tslint-disable-line max-line-length +type FactoryFunction = ( collection: Collection, n: number, done: Callback ) => void; /** * Interface for `someByRightAsync`. @@ -128,7 +128,6 @@ interface SomeByRightAsync { * - If a predicate function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. * - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`). * - * * @param collection - input collection * @param n - number of elements * @param options - function options @@ -175,7 +174,7 @@ interface SomeByRightAsync { * * someByRightAsync( files, 2, predicate, done ); */ - ( collection: Collection, n: number, options: Options, predicate: Predicate, done: Callback ): void; // tslint-disable-line max-line-length + ( collection: Collection, n: number, options: Options, predicate: Predicate, done: Callback ): void; /** * Tests whether a collection contains at least `n` elements which pass a test implemented by a predicate function, iterating from right to left. @@ -185,7 +184,6 @@ interface SomeByRightAsync { * - If a predicate function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. * - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`). * - * * @param collection - input collection * @param n - number of elements * @param predicate - predicate function to invoke for each element in a collection @@ -228,7 +226,7 @@ interface SomeByRightAsync { * * someByRightAsync( files, 2, predicate, done ); */ - ( collection: Collection, n: number, predicate: Predicate, done: Callback ): void; // tslint-disable-line max-line-length + ( collection: Collection, n: number, predicate: Predicate, done: Callback ): void; // tslint:disable-line:no-unnecessary-generics /** * Returns a function for testing whether a collection contains at least `n` elements which pass a test implemented by a predicate function, iterating from right to left. @@ -238,7 +236,6 @@ interface SomeByRightAsync { * - If a predicate function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. * - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`). * - * * @param options - function options * @param options.thisArg - execution context * @param options.limit - maximum number of pending invocations at any one time @@ -292,7 +289,7 @@ interface SomeByRightAsync { * // Try to read each element in `files`: * someByRightAsync( files, 2, done ); */ - factory( options: Options, predicate: Predicate ): FactoryFunction; + factory( options: Options, predicate: Predicate ): FactoryFunction; /** * Returns a function for testing whether a collection contains at least `n` elements which pass a test implemented by a predicate function, iterating from right to left. @@ -302,7 +299,6 @@ interface SomeByRightAsync { * - If a predicate function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. * - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`). * - * * @param predicate - predicate function to invoke for each element in a collection * @throws must provide valid options * @returns function which invokes the predicate function once for each element in a collection @@ -352,7 +348,7 @@ interface SomeByRightAsync { * // Try to read each element in `files`: * someByRightAsync( files, 2, done ); */ - factory( predicate: Predicate ): FactoryFunction; + factory( predicate: Predicate ): FactoryFunction; // tslint:disable-line:no-unnecessary-generics } /** @@ -363,7 +359,6 @@ interface SomeByRightAsync { * - If a predicate function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. * - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`). * -* * @param collection - input collection * @param n - number of elements * @param options - function options diff --git a/lib/node_modules/@stdlib/utils/async/some-by-right/docs/types/test.ts b/lib/node_modules/@stdlib/utils/async/some-by-right/docs/types/test.ts index 5d9c9163efb..bbdecc074f2 100644 --- a/lib/node_modules/@stdlib/utils/async/some-by-right/docs/types/test.ts +++ b/lib/node_modules/@stdlib/utils/async/some-by-right/docs/types/test.ts @@ -91,8 +91,8 @@ const done = ( error: Error | null, bool: boolean ) => { // Attached to main export is a `factory` method which returns a function... { - someByRightAsync.factory( isPositive ); // $ExpectType FactoryFunction - someByRightAsync.factory( { 'series': true }, isPositive ); // $ExpectType FactoryFunction + someByRightAsync.factory( isPositive ); // $ExpectType FactoryFunction + someByRightAsync.factory( { 'series': true }, isPositive ); // $ExpectType FactoryFunction } // The compiler throws an error if the `factory` method is provided an options argument which is not an object...