Skip to content

feat: add blas/ext/base/ndarray/gfind-index #7743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 9, 2025
Prev Previous commit
Next Next commit
docs: be more explicit that the callback is a predicate function
Signed-off-by: Athan <kgryte@gmail.com>
  • Loading branch information
kgryte authored Aug 9, 2025
commit 05d30f506fbc4550614a018a72271ba19cfe1f4b
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,55 @@
import { typedndarray } from '@stdlib/types/ndarray';

/**
* Returns the result of callback function.
* Returns a boolean indicating whether an element passes a test.
*
* @returns result
* @returns boolean indicating whether an element passes a test
*/
type Nullary<ThisArg> = ( this: ThisArg ) => boolean;

/**
* Returns the result of callback function.
* Returns a boolean indicating whether an element passes a test.
*
* @param value - current array element
* @returns result
* @returns boolean indicating whether an element passes a test
*/
type Unary<T, ThisArg> = ( this: ThisArg, value: T ) => boolean;

/**
* Returns the result of callback function.
* Returns a boolean indicating whether an element passes a test.
*
* @param value - current array element
* @param index - current array element index
* @returns result
* @returns boolean indicating whether an element passes a test
*/
type Binary<T, ThisArg> = ( this: ThisArg, value: T, index: number ) => boolean;

/**
* Returns the result of callback function.
* Returns a boolean indicating whether an element passes a test.
*
* @param value - current array element
* @param index - current array element index
* @param array - input ndarray
* @returns result
* @returns boolean indicating whether an element passes a test
*/
type Ternary<T, U, ThisArg> = ( this: ThisArg, value: T, index: number, array: U ) => boolean;

/**
* Returns the result of callback function.
* Returns a boolean indicating whether an element passes a test.
*
* @param value - current array element
* @param index - current array element index
* @param array - input ndarray
* @returns result
* @returns boolean indicating whether an element passes a test
*/
type Callback<T, U, ThisArg> = Nullary<ThisArg> | Unary<T, ThisArg> | Binary<T, ThisArg> | Ternary<T, U, ThisArg>;
type Predicate<T, U, ThisArg> = Nullary<ThisArg> | Unary<T, ThisArg> | Binary<T, ThisArg> | Ternary<T, U, ThisArg>;

/**
* Returns the index of the first element in a one-dimensional ndarray which passes a test implemented by a predicate function.
*
* @param arrays - array-like object containing an input ndarray
* @param clbk - callback function
* @param thisArg - callback execution context
* @param clbk - predicate function
* @param thisArg - predicate execution context
* @returns index
*
* @example
Expand All @@ -87,7 +87,7 @@ type Callback<T, U, ThisArg> = Nullary<ThisArg> | Unary<T, ThisArg> | Binary<T,
* var v = gfindIndex( [ x ], clbk );
* // returns 2
*/
declare function gfindIndex<T = unknown, U extends typedndarray<T> = typedndarray<T>, ThisArg = unknown>( arrays: [ U ], clbk: Callback<T, U, ThisArg>, thisArg?: ThisParameterType<Callback<T, U, ThisArg>> ): number;
declare function gfindIndex<T = unknown, U extends typedndarray<T> = typedndarray<T>, ThisArg = unknown>( arrays: [ U ], clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): number;


// EXPORTS //
Expand Down