Skip to content

Commit b57b376

Browse files
authored
refactor: use overloads to preserve type information
Signed-off-by: Athan <[email protected]>
1 parent e81c6fd commit b57b376

File tree

1 file changed

+20
-1
lines changed
  • lib/node_modules/@stdlib/array/base/for-each/docs/types

1 file changed

+20
-1
lines changed

lib/node_modules/@stdlib/array/base/for-each/docs/types/index.d.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@ type Ternary<T, U, V> = ( this: V, value: T, indices: Array<number>, arr: U ) =>
6060
*/
6161
type Callback<T, U, V> = Nullary<V> | Unary<T, V> | Binary<T, V> | Ternary<T, U, V>;
6262

63+
/**
64+
* Invokes a callback function once for each array element.
65+
*
66+
* @param x - input array
67+
* @param fcn - callback function
68+
* @param thisArg - callback function execution context
69+
*
70+
* @example
71+
* var naryFunction = require( '@stdlib/utils/nary-function' );
72+
* var toAccessorArray = require( '@stdlib/array/base/to-accessor' );
73+
* var log = require( '@stdlib/console/log' );
74+
*
75+
* var x = toAccesorArray( [ 1, 2, 3, 4] );
76+
*
77+
* // Apply the callback function:
78+
* forEach( x, naryFunction( log, 1 ) );
79+
*/
80+
declare function forEach<T = unknown, V = unknown>( x: AccessorArrayLike<T>, fcn: Callback<T, AccessorArrayLike<T>, V>, thisArg?: ThisParameterType<Callback<T, AccessorArrayLike<T>, V>> ): void;
81+
6382
/**
6483
* Invokes a callback function once for each array element.
6584
*
@@ -76,7 +95,7 @@ type Callback<T, U, V> = Nullary<V> | Unary<T, V> | Binary<T, V> | Ternary<T, U,
7695
* // Apply the callback function:
7796
* forEach( x, naryFunction( log, 1 ) );
7897
*/
79-
declare function forEach<T = unknown, U = unknown, V = unknown>( x: Collection<T> | AccessorArrayLike<U>, fcn: Callback<number, Collection<T>, V>, thisArg?: ThisParameterType<Callback<number, Collection<T>, V>> ): void;
98+
declare function forEach<T = unknown, V = unknown>( x: Collection<T>, fcn: Callback<T, Collection<T>, V>, thisArg?: ThisParameterType<Callback<T, Collection<T>, V>> ): void;
8099

81100

82101
// EXPORTS //

0 commit comments

Comments
 (0)