Skip to content

Commit fb8b73b

Browse files
committed
refactor: improve type inference and update descriptions
Ref: #856 Ref: 0aa7b4a
1 parent 3f1a75d commit fb8b73b

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

lib/node_modules/@stdlib/string/base/for-each-right/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# forEachRight
2222

23-
> Invokes a function for each UTF-16 code unit in a string iterating from right to left.
23+
> Invokes a function for each UTF-16 code unit in a string, iterating from right to left.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -42,7 +42,7 @@ var forEachRight = require( '@stdlib/string/base/for-each-right' );
4242

4343
#### forEachRight( str, clbk\[, thisArg ] )
4444

45-
Invokes a function for each UTF-16 code unit in a string iterating from right to left.
45+
Invokes a function for each UTF-16 code unit in a string, iterating from right to left.
4646

4747
```javascript
4848
function log( value, index ) {

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

+7-7
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 UTF-16 code unit in a string.
3030
*
3131
* @param value - character
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 UTF-16 code unit in a string.
@@ -40,7 +40,7 @@ type Unary = ( value: string ) => any;
4040
* @param index - character 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 UTF-16 code unit 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 UTF-16 code unit in a string.
@@ -60,10 +60,10 @@ 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
/**
66-
* Invokes a function for each UTF-16 code unit in a string iterating from right to left.
66+
* Invokes a function for each UTF-16 code unit in a string, iterating from right to left.
6767
*
6868
* ## Notes
6969
*
@@ -85,7 +85,7 @@ type Callback = Nullary | Unary | Binary | Ternary;
8585
*
8686
* forEach( 'Hello, World!', log );
8787
*/
88-
declare function forEachRight( str: string, clbk: Callback, thisArg?: any ): string;
88+
declare function forEachRight<T = unknown>( str: string, clbk: Callback<T>, thisArg?: ThisParameterType<Callback<T>> ): string;
8989

9090

9191
// EXPORTS //

lib/node_modules/@stdlib/string/base/for-each-right/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Invoke a function for each UTF-16 code unit in a string iterating from right to left.
22+
* Invoke a function for each UTF-16 code unit in a string, iterating from right to left.
2323
*
2424
* @module @stdlib/string/base/for-each-right
2525
*

lib/node_modules/@stdlib/string/base/for-each-right/lib/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MAIN //
2222

2323
/**
24-
* Invokes a function for each UTF-16 code unit in a string iterating from right to left.
24+
* Invokes a function for each UTF-16 code unit in a string, iterating from right to left.
2525
*
2626
* @param {string} str - input string
2727
* @param {Function} clbk - function to invoke

lib/node_modules/@stdlib/string/base/for-each-right/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/string/base/for-each-right",
33
"version": "0.0.0",
4-
"description": "Invoke a function for each UTF-16 code unit in a string iterating from right to left.",
4+
"description": "Invoke a function for each UTF-16 code unit in a string, iterating from right to left.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",

0 commit comments

Comments
 (0)