Skip to content

Commit 9357253

Browse files
committed
refactor: apply suggestions from code review
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent f561a3e commit 9357253

File tree

4 files changed

+77
-61
lines changed

4 files changed

+77
-61
lines changed

lib/node_modules/@stdlib/console/log-each-map/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ logEachMap( '%d + %d = %d', x, y, add );
5858

5959
The function accepts the following arguments:
6060

61-
- **str**: Format string.
62-
- **args**: Input arrays _(optional)_.
63-
- **clbk**: Callback function.
64-
- **thisArg**: Callback execution context _(optional)_.
61+
- **str**: format string.
62+
- **args**: input arrays _(optional)_.
63+
- **clbk**: callback function.
64+
- **thisArg**: callback execution context _(optional)_.
6565

6666
To set the callback execution context, provide a `thisArg`.
6767

@@ -103,9 +103,9 @@ logEachMap( '%d * %d = %d', x, y, multiply );
103103

104104
The callback function is provided the following arguments:
105105

106-
- **values**: Current array elements or broadcasted values.
107-
- **index**: Current element index.
108-
- **arrays**: Input arrays or broadcasted arrays.
106+
- **values**: current array elements or broadcasted values.
107+
- **index**: current element index.
108+
- **arrays**: input arrays or broadcasted arrays.
109109

110110
</section>
111111

lib/node_modules/@stdlib/console/log-each-map/docs/repl.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
{{alias}}( str[, ...args], clbk[, thisArg] )
23
Inserts array element values into a format string, applies a callback,
34
and prints the result.

lib/node_modules/@stdlib/console/log-each-map/docs/types/index.d.ts

Lines changed: 67 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,110 +18,124 @@
1818

1919
// TypeScript Version: 4.1
2020

21+
import { Array2D } from '@stdlib/types/array';
22+
2123
/**
2224
* Callback function that accepts no arguments.
25+
*
26+
* @returns result
2327
*/
24-
type NullaryCallback = () => any;
28+
type NullaryCallback<U> = ( this: U ) => any;
2529

2630
/**
2731
* Callback function that accepts one argument.
32+
*
33+
* @param value - current array elements or broadcasted values
34+
* @returns result
2835
*/
29-
type UnaryCallback = ( x: any ) => any;
36+
type UnaryCallback<U> = ( this: U, x: unknown ) => any;
3037

3138
/**
3239
* Callback function that accepts two arguments.
40+
*
41+
* @param firstValue - first array element or broadcasted value
42+
* @param secondValue - second array element or broadcasted value
43+
* @returns result
3344
*/
34-
type BinaryCallback = ( x: any, y: any ) => any;
45+
type BinaryCallback<U> = ( this: U, x: unknown, y: unknown ) => any;
3546

3647
/**
37-
* Callback function that accepts three arguments.
48+
* Callback function that accepts three arguments
49+
*
50+
* @param firstValue - first array element or broadcasted value
51+
* @param secondValue - second array element or broadcasted value
52+
* @param thirdValue - third array element or broadcasted value
53+
* @returns result
3854
*/
39-
type TernaryCallback = ( x: any, y: any, z: any ) => any;
55+
type TernaryCallback<U> = ( this: U, x: unknown, y: unknown, z: unknown ) => any;
4056

4157
/**
4258
* Callback function that accepts four arguments.
59+
*
60+
* @param firstValue - first array element or broadcasted value
61+
* @param secondValue - second array element or broadcasted value
62+
* @param thirdValue - third array element or broadcasted value
63+
* @param index - current array element index
64+
* @returns result
4365
*/
44-
type QuaternaryCallback = ( w: any, x: any, y: any, z: any ) => any;
66+
type QuaternaryCallback<U> = ( this: U, x: unknown, y: unknown, z: unknown, index: number ) => any;
4567

4668
/**
4769
* Callback function that accepts five arguments.
48-
*/
49-
type QuinaryCallback = ( v: any, w: any, x: any, y: any, z: any ) => any;
50-
51-
/**
52-
* Inserts array element values into a format string, applies a callback, and prints the result.
5370
*
54-
* @param str - Format string
55-
* @param clbk - Callback function
56-
* @param thisArg - Callback execution context
71+
* @param firstValue - first array element or broadcasted value
72+
* @param secondValue - second array element or broadcasted value
73+
* @param thirdValue - third array element or broadcasted value
74+
* @param index - current array element index
75+
* @param arrays - input arrays or broadcasted arrays
76+
* @returns result
5777
*/
58-
declare function logEachMap( str: string, clbk: NullaryCallback, thisArg?: any ): void;
78+
type QuinaryCallback<T, U> = ( this: U, x: unknown, y: unknown, z: unknown, index: number, arrays: Array2D<T> ) => any;
5979

6080
/**
61-
* Inserts array element values into a format string, applies a callback, and prints the result.
81+
* Callback invoked for each value.
6282
*
63-
* @param str - Format string
64-
* @param arg0 - Input array or scalar value
65-
* @param clbk - Callback function
66-
* @param thisArg - Callback execution context
83+
* @param firstValue - first array element or broadcasted value
84+
* @param secondValue - second array element or broadcasted value
85+
* @param thirdValue - third array element or broadcasted value
86+
* @param index - current array element index
87+
* @param arrays - input arrays or broadcasted arrays
88+
* @returns result
6789
*/
68-
declare function logEachMap( str: string, arg0: any, clbk: UnaryCallback, thisArg?: any ): void;
90+
type Callback<T, U> = NullaryCallback<U> | UnaryCallback<U> | BinaryCallback<U> | TernaryCallback<U> | QuaternaryCallback<U> | QuinaryCallback<T,U>;
6991

7092
/**
7193
* Inserts array element values into a format string, applies a callback, and prints the result.
7294
*
73-
* @param str - Format string
74-
* @param arg0 - First input array or scalar value
75-
* @param arg1 - Second input array or scalar value
76-
* @param clbk - Callback function
77-
* @param thisArg - Callback execution context
95+
* @param str - format string
96+
* @param clbk - callback function
97+
* @param thisArg - callback execution context
7898
*/
79-
declare function logEachMap( str: string, arg0: any, arg1: any, clbk: BinaryCallback, thisArg?: any ): void;
99+
declare function logEachMap<T = unknown, U = unknown>( str: string, clbk: Callback<T,U>, thisArg?: any ): void;
80100

81101
/**
82102
* Inserts array element values into a format string, applies a callback, and prints the result.
83103
*
84-
* @param str - Format string
85-
* @param arg0 - First input array or scalar value
86-
* @param arg1 - Second input array or scalar value
87-
* @param arg2 - Third input array or scalar value
88-
* @param clbk - Callback function
89-
* @param thisArg - Callback execution context
104+
* @param str - format string
105+
* @param arg0 - input array or scalar value
106+
* @param clbk - callback function
107+
* @param thisArg - callback execution context
90108
*/
91-
declare function logEachMap( str: string, arg0: any, arg1: any, arg2: any, clbk: TernaryCallback, thisArg?: any ): void;
109+
declare function logEachMap<T = unknown, U = unknown>( str: string, arg0: unknown, clbk: Callback<T,U>, thisArg?: any ): void;
92110

93111
/**
94112
* Inserts array element values into a format string, applies a callback, and prints the result.
95113
*
96-
* @param str - Format string
97-
* @param arg0 - First input array or scalar value
98-
* @param arg1 - Second input array or scalar value
99-
* @param arg2 - Third input array or scalar value
100-
* @param arg3 - Fourth input array or scalar value
101-
* @param clbk - Callback function
102-
* @param thisArg - Callback execution context
114+
* @param str - format string
115+
* @param arg0 - first input array or scalar value
116+
* @param arg1 - second input array or scalar value
117+
* @param clbk - callback function
118+
* @param thisArg - callback execution context
103119
*/
104-
declare function logEachMap( str: string, arg0: any, arg1: any, arg2: any, arg3: any, clbk: QuaternaryCallback, thisArg?: any ): void;
120+
declare function logEachMap<T = unknown, U = unknown>( str: string, arg0: unknown, arg1: unknown, clbk: Callback<T,U>, thisArg?: any ): void;
105121

106122
/**
107123
* Inserts array element values into a format string, applies a callback, and prints the result.
108124
*
109-
* @param str - Format string
110-
* @param arg0 - First input array or scalar value
111-
* @param arg1 - Second input array or scalar value
112-
* @param arg2 - Third input array or scalar value
113-
* @param arg3 - Fourth input array or scalar value
114-
* @param arg4 - Fifth input array or scalar value
115-
* @param clbk - Callback function
116-
* @param thisArg - Callback execution context
125+
* @param str - format string
126+
* @param arg0 - first input array or scalar value
127+
* @param arg1 - second input array or scalar value
128+
* @param arg2 - third input array or scalar value
129+
* @param clbk - callback function
130+
* @param thisArg - callback execution context
117131
*/
118-
declare function logEachMap( str: string, arg0: any, arg1: any, arg2: any, arg3: any, arg4: any, clbk: QuinaryCallback, thisArg?: any ): void;
132+
declare function logEachMap<T = unknown, U = unknown>( str: string, arg0: unknown, arg1: unknown, arg2: unknown, clbk: Callback<T,U>, thisArg?: any ): void;
119133

120134
/**
121135
* Inserts array element values into a format string, applies a callback, and prints the result.
122136
*
123-
* @param str - Format string
124-
* @param args - Input arrays or values
137+
* @param str - format string
138+
* @param args - input arrays or values
125139
*/
126140
declare function logEachMap( str: string, ...args: Array<unknown> ): void;
127141

lib/node_modules/@stdlib/console/log-each-map/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var isFunction = require( '@stdlib/assert/is-function' );
2525
var isCollection = require( '@stdlib/assert/is-collection' );
2626
var resolveGetter = require( '@stdlib/array/base/resolve-getter' );
27+
var nulls = require( '@stdlib/array/base/nulls' );
2728
var format = require( '@stdlib/string/format' );
2829
var logger = require( '@stdlib/console/log' );
2930

@@ -140,7 +141,7 @@ function logEachMap() {
140141
offsets.push( 0 );
141142
}
142143

143-
cbArgs = [];
144+
cbArgs = nulls( n + 2 );
144145
cbArgs[ n + 1 ] = args;
145146
for ( i = 0; i < len; i++ ) {
146147
for ( j = 0; j < n; j++ ) {

0 commit comments

Comments
 (0)