Skip to content

Commit bd6ee6f

Browse files
committed
refactor: improve type inference
1 parent ae446ec commit bd6ee6f

File tree

1 file changed

+6
-6
lines changed
  • lib/node_modules/@stdlib/string/base/for-each-grapheme-cluster/docs/types

1 file changed

+6
-6
lines changed

lib/node_modules/@stdlib/string/base/for-each-grapheme-cluster/docs/types/index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
*
2424
* @returns result
2525
*/
26-
type Nullary = () => any;
26+
type Nullary<T> = ( this: T ) => any;
2727

2828
/**
2929
* Callback invoked for each grapheme cluster (i.e., user-perceived character) in a string.
3030
*
3131
* @param value - grapheme cluster
3232
* @returns result
3333
*/
34-
type Unary = ( value: string ) => any;
34+
type Unary<T> = ( this: T, value: string ) => any;
3535

3636
/**
3737
* Callback invoked for each grapheme cluster (i.e., user-perceived character) in a string.
@@ -40,7 +40,7 @@ type Unary = ( value: string ) => any;
4040
* @param index - starting grapheme cluster index
4141
* @returns result
4242
*/
43-
type Binary = ( value: string, index: number ) => any;
43+
type Binary<T> = ( this: T, value: string, index: number ) => any;
4444

4545
/**
4646
* Callback invoked for each grapheme cluster (i.e., user-perceived character) in a string.
@@ -50,7 +50,7 @@ type Binary = ( value: string, index: number ) => any;
5050
* @param str - input string
5151
* @returns result
5252
*/
53-
type Ternary = ( value: string, index: number, str: string ) => any;
53+
type Ternary<T> = ( this: T, value: string, index: number, str: string ) => any;
5454

5555
/**
5656
* Callback invoked for each grapheme cluster (i.e., user-perceived character) in a string.
@@ -60,7 +60,7 @@ type Ternary = ( value: string, index: number, str: string ) => any;
6060
* @param str - input string
6161
* @returns result
6262
*/
63-
type Callback = Nullary | Unary | Binary | Ternary;
63+
type Callback<T> = Nullary<T> | Unary<T> | Binary<T> | Ternary<T>;
6464

6565
/**
6666
* Invokes a function for each grapheme cluster (i.e., user-perceived character) in a string.
@@ -85,7 +85,7 @@ type Callback = Nullary | Unary | Binary | Ternary;
8585
*
8686
* forEach( 'Hello, World!', log );
8787
*/
88-
declare function forEach( str: string, clbk: Callback, thisArg?: any ): string;
88+
declare function forEach<T = unknown>( str: string, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): string;
8989

9090

9191
// EXPORTS //

0 commit comments

Comments
 (0)