@stdlib/console-log-each-map 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +280 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +599 -0
- package/lib/index.js +67 -0
- package/lib/main.js +188 -0
- package/package.json +79 -0
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
import { Collection, AccessorArrayLike } from '@stdlib/types/array';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Input array.
|
|
25
|
+
*/
|
|
26
|
+
type InputArray<T> = Collection<T> | AccessorArrayLike<T>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Nullary callback.
|
|
30
|
+
*
|
|
31
|
+
* @returns result
|
|
32
|
+
*/
|
|
33
|
+
type NullaryCallback<ThisArg> = ( this: ThisArg ) => any;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Unary callback.
|
|
37
|
+
*
|
|
38
|
+
* @param x - current array element
|
|
39
|
+
* @returns result
|
|
40
|
+
*/
|
|
41
|
+
type UnaryFcn<T, ThisArg> = ( this: ThisArg, x: T ) => any;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Unary callback.
|
|
45
|
+
*
|
|
46
|
+
* @param x - current array element
|
|
47
|
+
* @param index - current array element index
|
|
48
|
+
* @param arrays - input arrays
|
|
49
|
+
* @returns result
|
|
50
|
+
*/
|
|
51
|
+
type UnaryArgsFcn<T, U, ThisArg> = ( this: ThisArg, x: T, index: number, arrays?: [ U ] ) => any;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Unary callback.
|
|
55
|
+
*
|
|
56
|
+
* @param x - current array element
|
|
57
|
+
* @param index - current array element index
|
|
58
|
+
* @param arrays - input arrays
|
|
59
|
+
* @returns result
|
|
60
|
+
*/
|
|
61
|
+
type UnaryCallback<T, U, ThisArg> = UnaryFcn<T, ThisArg> | UnaryArgsFcn<T, U, ThisArg>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Binary callback.
|
|
65
|
+
*
|
|
66
|
+
* @param x - current first array element
|
|
67
|
+
* @param y - current second array element
|
|
68
|
+
* @returns result
|
|
69
|
+
*/
|
|
70
|
+
type BinaryFcn<T, V, ThisArg> = ( this: ThisArg, x: T, y: V ) => any;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Binary callback.
|
|
74
|
+
*
|
|
75
|
+
* @param x - current first array element
|
|
76
|
+
* @param y - current second array element
|
|
77
|
+
* @param index - current array element index
|
|
78
|
+
* @param arrays - input arrays
|
|
79
|
+
* @returns result
|
|
80
|
+
*/
|
|
81
|
+
type BinaryArgsFcn<T, U, V, W, ThisArg> = ( this: ThisArg, x: T, y: V, index: number, arrays?: [ U, W ] ) => any;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Binary callback.
|
|
85
|
+
*
|
|
86
|
+
* @param x - current first array element
|
|
87
|
+
* @param y - current second array element
|
|
88
|
+
* @param index - current array element index
|
|
89
|
+
* @param arrays - input arrays
|
|
90
|
+
* @returns result
|
|
91
|
+
*/
|
|
92
|
+
type BinaryCallback<T, U, V, W, ThisArg> = BinaryFcn<T, V, ThisArg> | BinaryArgsFcn<T, U, V, W, ThisArg>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Ternary callback.
|
|
96
|
+
*
|
|
97
|
+
* @param x - current first array element
|
|
98
|
+
* @param y - current second array element
|
|
99
|
+
* @param z - current third array element
|
|
100
|
+
* @returns result
|
|
101
|
+
*/
|
|
102
|
+
type TernaryFcn<T, V, X, ThisArg> = ( this: ThisArg, x: T, y: V, z: X ) => any;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Ternary callback.
|
|
106
|
+
*
|
|
107
|
+
* @param x - current first array element
|
|
108
|
+
* @param y - current second array element
|
|
109
|
+
* @param z - current third array element
|
|
110
|
+
* @param index - current array element index
|
|
111
|
+
* @param arrays - input arrays
|
|
112
|
+
* @returns result
|
|
113
|
+
*/
|
|
114
|
+
type TernaryArgsFcn<T, U, V, W, X, Y, ThisArg> = ( this: ThisArg, x: T, y: V, z: X, index: number, arrays?: [ U, W, Y ] ) => any;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Ternary callback.
|
|
118
|
+
*
|
|
119
|
+
* @param x - current first array element
|
|
120
|
+
* @param y - current second array element
|
|
121
|
+
* @param z - current third array element
|
|
122
|
+
* @param index - current array element index
|
|
123
|
+
* @param arrays - input arrays
|
|
124
|
+
* @returns result
|
|
125
|
+
*/
|
|
126
|
+
type TernaryCallback<T, U, V, W, X, Y, ThisArg> = TernaryFcn<T, V, X, ThisArg> | TernaryArgsFcn<T, U, V, W, X, Y, ThisArg>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Callback.
|
|
130
|
+
*
|
|
131
|
+
* @param args - callback arguments
|
|
132
|
+
* @returns results
|
|
133
|
+
*/
|
|
134
|
+
type Callback<ThisArg> = ( this: ThisArg, ...args: Array<unknown> ) => any;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Inserts the result of a callback function into a format string and prints the result.
|
|
138
|
+
*
|
|
139
|
+
* @param str - format string
|
|
140
|
+
* @param clbk - callback function
|
|
141
|
+
* @param thisArg - callback execution context
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* function clbk() {
|
|
145
|
+
* return 'beep';
|
|
146
|
+
* }
|
|
147
|
+
*
|
|
148
|
+
* logEachMap( '%s', clbk );
|
|
149
|
+
* // e.g., => 'beep\n'
|
|
150
|
+
*/
|
|
151
|
+
declare function logEachMap<ThisArg = unknown>( str: string, clbk: NullaryCallback<ThisArg>, thisArg?: ThisParameterType<NullaryCallback<ThisArg>> ): void;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
155
|
+
*
|
|
156
|
+
* @param str - format string
|
|
157
|
+
* @param arg0 - input array
|
|
158
|
+
* @param clbk - callback function
|
|
159
|
+
* @param thisArg - callback execution context
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* function clbk( v ) {
|
|
163
|
+
* return v * 2;
|
|
164
|
+
* }
|
|
165
|
+
*
|
|
166
|
+
* var x = [ 1, 2, 3 ];
|
|
167
|
+
*
|
|
168
|
+
* logEachMap( '%d', x, clbk );
|
|
169
|
+
* // e.g., => '2\n4\n6\n'
|
|
170
|
+
*/
|
|
171
|
+
declare function logEachMap<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( str: string, arg0: U, clbk: UnaryCallback<T, U, ThisArg>, thisArg?: ThisParameterType<UnaryCallback<T, U, ThisArg>> ): void;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
175
|
+
*
|
|
176
|
+
* ## Notes
|
|
177
|
+
*
|
|
178
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
179
|
+
*
|
|
180
|
+
* @param str - format string
|
|
181
|
+
* @param arg0 - input value
|
|
182
|
+
* @param clbk - callback function
|
|
183
|
+
* @param thisArg - callback execution context
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* function clbk( v ) {
|
|
187
|
+
* return v * 2;
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* logEachMap( '%d', 1, clbk );
|
|
191
|
+
* // e.g., => '2\n'
|
|
192
|
+
*/
|
|
193
|
+
declare function logEachMap<T = unknown, ThisArg = unknown>( str: string, arg0: T, clbk: UnaryCallback<T, [ T ], ThisArg>, thisArg?: ThisParameterType<UnaryCallback<T, [ T ], ThisArg>> ): void;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
197
|
+
*
|
|
198
|
+
* @param str - format string
|
|
199
|
+
* @param arg0 - first input array
|
|
200
|
+
* @param arg1 - second input array
|
|
201
|
+
* @param clbk - callback function
|
|
202
|
+
* @param thisArg - callback execution context
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* function clbk( x, y ) {
|
|
206
|
+
* return x + y;
|
|
207
|
+
* }
|
|
208
|
+
*
|
|
209
|
+
* var x = [ 1, 2, 3 ];
|
|
210
|
+
* var y = [ 4, 5, 6 ];
|
|
211
|
+
*
|
|
212
|
+
* logEachMap( '%d', x, y, clbk );
|
|
213
|
+
* // e.g., => '5\n7\n9\n'
|
|
214
|
+
*/
|
|
215
|
+
declare function logEachMap<
|
|
216
|
+
T = unknown,
|
|
217
|
+
U extends InputArray<T> = InputArray<T>,
|
|
218
|
+
V = unknown,
|
|
219
|
+
W extends InputArray<V> = InputArray<V>,
|
|
220
|
+
ThisArg = unknown
|
|
221
|
+
>( str: string, arg0: U, arg1: W, clbk: BinaryCallback<T, U, V, W, ThisArg>, thisArg?: ThisParameterType<BinaryCallback<T, U, V, W, ThisArg>> ): void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
225
|
+
*
|
|
226
|
+
* ## Notes
|
|
227
|
+
*
|
|
228
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
229
|
+
*
|
|
230
|
+
* @param str - format string
|
|
231
|
+
* @param arg0 - first input value
|
|
232
|
+
* @param arg1 - second input array
|
|
233
|
+
* @param clbk - callback function
|
|
234
|
+
* @param thisArg - callback execution context
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* function clbk( x, y ) {
|
|
238
|
+
* return x + y;
|
|
239
|
+
* }
|
|
240
|
+
*
|
|
241
|
+
* var y = [ 4, 5, 6 ];
|
|
242
|
+
*
|
|
243
|
+
* logEachMap( '%d', 1, y, clbk );
|
|
244
|
+
* // e.g., => '5\n6\n7\n'
|
|
245
|
+
*/
|
|
246
|
+
declare function logEachMap<
|
|
247
|
+
T = unknown,
|
|
248
|
+
V = unknown,
|
|
249
|
+
W extends InputArray<V> = InputArray<V>,
|
|
250
|
+
ThisArg = unknown
|
|
251
|
+
>( str: string, arg0: T, arg1: W, clbk: BinaryCallback<T, [ T ], V, W, ThisArg>, thisArg?: ThisParameterType<BinaryCallback<T, [ T ], V, W, ThisArg>> ): void;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
255
|
+
*
|
|
256
|
+
* ## Notes
|
|
257
|
+
*
|
|
258
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
259
|
+
*
|
|
260
|
+
* @param str - format string
|
|
261
|
+
* @param arg0 - first input array
|
|
262
|
+
* @param arg1 - second input value
|
|
263
|
+
* @param clbk - callback function
|
|
264
|
+
* @param thisArg - callback execution context
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* function clbk( x, y ) {
|
|
268
|
+
* return x + y;
|
|
269
|
+
* }
|
|
270
|
+
*
|
|
271
|
+
* var x = [ 1, 2, 3 ];
|
|
272
|
+
*
|
|
273
|
+
* logEachMap( '%d', x, 1, clbk );
|
|
274
|
+
* // e.g., => '2\n3\n4\n'
|
|
275
|
+
*/
|
|
276
|
+
declare function logEachMap<
|
|
277
|
+
T = unknown,
|
|
278
|
+
U extends InputArray<T> = InputArray<T>,
|
|
279
|
+
V = unknown,
|
|
280
|
+
ThisArg = unknown
|
|
281
|
+
>( str: string, arg0: T, arg1: V, clbk: BinaryCallback<T, U, V, [ V ], ThisArg>, thisArg?: ThisParameterType<BinaryCallback<T, U, V, [ V ], ThisArg>> ): void;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
285
|
+
*
|
|
286
|
+
* ## Notes
|
|
287
|
+
*
|
|
288
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
289
|
+
*
|
|
290
|
+
* @param str - format string
|
|
291
|
+
* @param arg0 - first input value
|
|
292
|
+
* @param arg1 - second input value
|
|
293
|
+
* @param clbk - callback function
|
|
294
|
+
* @param thisArg - callback execution context
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* function clbk( x, y ) {
|
|
298
|
+
* return x + y;
|
|
299
|
+
* }
|
|
300
|
+
*
|
|
301
|
+
* logEachMap( '%d', 1, 2, clbk );
|
|
302
|
+
* // e.g., => '3\n'
|
|
303
|
+
*/
|
|
304
|
+
declare function logEachMap<
|
|
305
|
+
T = unknown,
|
|
306
|
+
V = unknown,
|
|
307
|
+
ThisArg = unknown
|
|
308
|
+
>( str: string, arg0: T, arg1: V, clbk: BinaryCallback<T, [ T ], V, [ V ], ThisArg>, thisArg?: ThisParameterType<BinaryCallback<T, [ T ], V, [ V ], ThisArg>> ): void;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
312
|
+
*
|
|
313
|
+
* @param str - format string
|
|
314
|
+
* @param arg0 - first input array
|
|
315
|
+
* @param arg1 - second input array
|
|
316
|
+
* @param arg2 - third input array
|
|
317
|
+
* @param clbk - callback function
|
|
318
|
+
* @param thisArg - callback execution context
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* function clbk( x, y, z ) {
|
|
322
|
+
* return x + y + z;
|
|
323
|
+
* }
|
|
324
|
+
*
|
|
325
|
+
* var x = [ 1, 2, 3 ];
|
|
326
|
+
* var y = [ 4, 5, 6 ];
|
|
327
|
+
* var z = [ 7, 8, 9 ];
|
|
328
|
+
*
|
|
329
|
+
* logEachMap( '%d', x, y, z, clbk );
|
|
330
|
+
* // e.g., => '12\n15\n18\n'
|
|
331
|
+
*/
|
|
332
|
+
declare function logEachMap<
|
|
333
|
+
T = unknown,
|
|
334
|
+
U extends InputArray<T> = InputArray<T>,
|
|
335
|
+
V = unknown,
|
|
336
|
+
W extends InputArray<V> = InputArray<V>,
|
|
337
|
+
X = unknown,
|
|
338
|
+
Y extends InputArray<X> = InputArray<X>,
|
|
339
|
+
ThisArg = unknown
|
|
340
|
+
>( str: string, arg0: U, arg1: W, arg2: Y, clbk: TernaryCallback<T, U, V, W, X, Y, ThisArg>, thisArg?: ThisParameterType<TernaryCallback<T, U, V, W, X, Y, ThisArg>> ): void;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
344
|
+
*
|
|
345
|
+
* ## Notes
|
|
346
|
+
*
|
|
347
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
348
|
+
*
|
|
349
|
+
* @param str - format string
|
|
350
|
+
* @param arg0 - first input value
|
|
351
|
+
* @param arg1 - second input array
|
|
352
|
+
* @param arg2 - third input array
|
|
353
|
+
* @param clbk - callback function
|
|
354
|
+
* @param thisArg - callback execution context
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* function clbk( x, y, z ) {
|
|
358
|
+
* return x + y + z;
|
|
359
|
+
* }
|
|
360
|
+
*
|
|
361
|
+
* var y = [ 4, 5, 6 ];
|
|
362
|
+
* var z = [ 7, 8, 9 ];
|
|
363
|
+
*
|
|
364
|
+
* logEachMap( '%d', 1, y, z, clbk );
|
|
365
|
+
* // e.g., => '12\n14\n16\n'
|
|
366
|
+
*/
|
|
367
|
+
declare function logEachMap<
|
|
368
|
+
T = unknown,
|
|
369
|
+
V = unknown,
|
|
370
|
+
W extends InputArray<V> = InputArray<V>,
|
|
371
|
+
X = unknown,
|
|
372
|
+
Y extends InputArray<X> = InputArray<X>,
|
|
373
|
+
ThisArg = unknown
|
|
374
|
+
>( str: string, arg0: T, arg1: W, arg2: Y, clbk: TernaryCallback<T, [ T ], V, W, X, Y, ThisArg>, thisArg?: ThisParameterType<TernaryCallback<T, [ T ], V, W, X, Y, ThisArg>> ): void;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
378
|
+
*
|
|
379
|
+
* ## Notes
|
|
380
|
+
*
|
|
381
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
382
|
+
*
|
|
383
|
+
* @param str - format string
|
|
384
|
+
* @param arg0 - first input array
|
|
385
|
+
* @param arg1 - second input value
|
|
386
|
+
* @param arg2 - third input array
|
|
387
|
+
* @param clbk - callback function
|
|
388
|
+
* @param thisArg - callback execution context
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* function clbk( x, y, z ) {
|
|
392
|
+
* return x + y + z;
|
|
393
|
+
* }
|
|
394
|
+
*
|
|
395
|
+
* var x = [ 1, 2, 3 ];
|
|
396
|
+
* var z = [ 7, 8, 9 ];
|
|
397
|
+
*
|
|
398
|
+
* logEachMap( '%d', x, 1, z, clbk );
|
|
399
|
+
* // e.g., => '9\n11\n13\n'
|
|
400
|
+
*/
|
|
401
|
+
declare function logEachMap<
|
|
402
|
+
T = unknown,
|
|
403
|
+
U extends InputArray<T> = InputArray<T>,
|
|
404
|
+
V = unknown,
|
|
405
|
+
X = unknown,
|
|
406
|
+
Y extends InputArray<X> = InputArray<X>,
|
|
407
|
+
ThisArg = unknown
|
|
408
|
+
>( str: string, arg0: U, arg1: V, arg2: Y, clbk: TernaryCallback<T, U, V, [ V ], X, Y, ThisArg>, thisArg?: ThisParameterType<TernaryCallback<T, U, V, [ V ], X, Y, ThisArg>> ): void;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
412
|
+
*
|
|
413
|
+
* ## Notes
|
|
414
|
+
*
|
|
415
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
416
|
+
*
|
|
417
|
+
* @param str - format string
|
|
418
|
+
* @param arg0 - first input array
|
|
419
|
+
* @param arg1 - second input array
|
|
420
|
+
* @param arg2 - third input value
|
|
421
|
+
* @param clbk - callback function
|
|
422
|
+
* @param thisArg - callback execution context
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* function clbk( x, y, z ) {
|
|
426
|
+
* return x + y + z;
|
|
427
|
+
* }
|
|
428
|
+
*
|
|
429
|
+
* var x = [ 1, 2, 3 ];
|
|
430
|
+
* var y = [ 4, 5, 6 ];
|
|
431
|
+
*
|
|
432
|
+
* logEachMap( '%d', x, y, 1, clbk );
|
|
433
|
+
* // e.g., => '6\n8\n10\n'
|
|
434
|
+
*/
|
|
435
|
+
declare function logEachMap<
|
|
436
|
+
T = unknown,
|
|
437
|
+
U extends InputArray<T> = InputArray<T>,
|
|
438
|
+
V = unknown,
|
|
439
|
+
W extends InputArray<V> = InputArray<V>,
|
|
440
|
+
X = unknown,
|
|
441
|
+
ThisArg = unknown
|
|
442
|
+
>( str: string, arg0: U, arg1: W, arg2: X, clbk: TernaryCallback<T, U, V, W, X, [ X ], ThisArg>, thisArg?: ThisParameterType<TernaryCallback<T, U, V, W, X, [ X ], ThisArg>> ): void;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
446
|
+
*
|
|
447
|
+
* ## Notes
|
|
448
|
+
*
|
|
449
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
450
|
+
*
|
|
451
|
+
* @param str - format string
|
|
452
|
+
* @param arg0 - first input value
|
|
453
|
+
* @param arg1 - second input value
|
|
454
|
+
* @param arg2 - third input array
|
|
455
|
+
* @param clbk - callback function
|
|
456
|
+
* @param thisArg - callback execution context
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* function clbk( x, y, z ) {
|
|
460
|
+
* return x + y + z;
|
|
461
|
+
* }
|
|
462
|
+
*
|
|
463
|
+
* var z = [ 7, 8, 9 ];
|
|
464
|
+
*
|
|
465
|
+
* logEachMap( '%d', 1, 2, z, clbk );
|
|
466
|
+
* // e.g., => '10\n11\n12\n'
|
|
467
|
+
*/
|
|
468
|
+
declare function logEachMap<
|
|
469
|
+
T = unknown,
|
|
470
|
+
V = unknown,
|
|
471
|
+
X = unknown,
|
|
472
|
+
Y extends InputArray<X> = InputArray<X>,
|
|
473
|
+
ThisArg = unknown
|
|
474
|
+
>( str: string, arg0: T, arg1: V, arg2: Y, clbk: TernaryCallback<T, [ T ], V, [ V ], X, Y, ThisArg>, thisArg?: ThisParameterType<TernaryCallback<T, [ T ], V, [ V ], X, Y, ThisArg>> ): void;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
478
|
+
*
|
|
479
|
+
* ## Notes
|
|
480
|
+
*
|
|
481
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
482
|
+
*
|
|
483
|
+
* @param str - format string
|
|
484
|
+
* @param arg0 - first input value
|
|
485
|
+
* @param arg1 - second input value
|
|
486
|
+
* @param arg2 - third input array
|
|
487
|
+
* @param clbk - callback function
|
|
488
|
+
* @param thisArg - callback execution context
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* function clbk( x, y, z ) {
|
|
492
|
+
* return x + y + z;
|
|
493
|
+
* }
|
|
494
|
+
*
|
|
495
|
+
* var y = [ 4, 5, 6 ];
|
|
496
|
+
*
|
|
497
|
+
* logEachMap( '%d', 1, y, 2, clbk );
|
|
498
|
+
* // e.g., => '7\n8\n9\n'
|
|
499
|
+
*/
|
|
500
|
+
declare function logEachMap<
|
|
501
|
+
T = unknown,
|
|
502
|
+
V = unknown,
|
|
503
|
+
W extends InputArray<V> = InputArray<V>,
|
|
504
|
+
X = unknown,
|
|
505
|
+
ThisArg = unknown
|
|
506
|
+
>( str: string, arg0: T, arg1: W, arg2: X, clbk: TernaryCallback<T, [ T ], V, W, X, [ X ], ThisArg>, thisArg?: ThisParameterType<TernaryCallback<T, [ T ], V, W, X, [ X ], ThisArg>> ): void;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
510
|
+
*
|
|
511
|
+
* ## Notes
|
|
512
|
+
*
|
|
513
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
514
|
+
*
|
|
515
|
+
* @param str - format string
|
|
516
|
+
* @param arg0 - first input array
|
|
517
|
+
* @param arg1 - second input value
|
|
518
|
+
* @param arg2 - third input value
|
|
519
|
+
* @param clbk - callback function
|
|
520
|
+
* @param thisArg - callback execution context
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* function clbk( x, y, z ) {
|
|
524
|
+
* return x + y + z;
|
|
525
|
+
* }
|
|
526
|
+
*
|
|
527
|
+
* var x = [ 1, 2, 3 ];
|
|
528
|
+
*
|
|
529
|
+
* logEachMap( '%d', x, 1, 2, clbk );
|
|
530
|
+
* // e.g., => '4\n5\n6\n'
|
|
531
|
+
*/
|
|
532
|
+
declare function logEachMap<
|
|
533
|
+
T = unknown,
|
|
534
|
+
U extends InputArray<T> = InputArray<T>,
|
|
535
|
+
V = unknown,
|
|
536
|
+
X = unknown,
|
|
537
|
+
ThisArg = unknown
|
|
538
|
+
>( str: string, arg0: U, arg1: V, arg2: X, clbk: TernaryCallback<T, U, V, [ V ], X, [ X ], ThisArg>, thisArg?: ThisParameterType<TernaryCallback<T, U, V, [ V ], X, [ X ], ThisArg>> ): void;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
542
|
+
*
|
|
543
|
+
* ## Notes
|
|
544
|
+
*
|
|
545
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
546
|
+
*
|
|
547
|
+
* @param str - format string
|
|
548
|
+
* @param arg0 - first input value
|
|
549
|
+
* @param arg1 - second input value
|
|
550
|
+
* @param arg2 - third input value
|
|
551
|
+
* @param clbk - callback function
|
|
552
|
+
* @param thisArg - callback execution context
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* function clbk( x, y, z ) {
|
|
556
|
+
* return x + y + z;
|
|
557
|
+
* }
|
|
558
|
+
*
|
|
559
|
+
* logEachMap( '%d', 1, 2, 3, clbk );
|
|
560
|
+
* // e.g., => '6\n'
|
|
561
|
+
*/
|
|
562
|
+
declare function logEachMap<
|
|
563
|
+
T = unknown,
|
|
564
|
+
V = unknown,
|
|
565
|
+
X = unknown,
|
|
566
|
+
ThisArg = unknown
|
|
567
|
+
>( str: string, arg0: T, arg1: V, arg2: X, clbk: TernaryCallback<T, [ T ], V, [ V ], X, [ X ], ThisArg>, thisArg?: ThisParameterType<TernaryCallback<T, [ T ], V, [ V ], X, [ X ], ThisArg>> ): void;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Inserts array element values and the result of a callback function into a format string and prints the result.
|
|
571
|
+
*
|
|
572
|
+
* ## Notes
|
|
573
|
+
*
|
|
574
|
+
* - If an interpolated argument is not a collection, the argument is broadcasted for each iteration.
|
|
575
|
+
*
|
|
576
|
+
* @param str - format string
|
|
577
|
+
* @param arg0 - first input value
|
|
578
|
+
* @param arg1 - second input value
|
|
579
|
+
* @param arg2 - third input value
|
|
580
|
+
* @param args - additional input values
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* function clbk( x, y, z ) {
|
|
584
|
+
* return x + y + z;
|
|
585
|
+
* }
|
|
586
|
+
*
|
|
587
|
+
* var x = [ 1, 2, 3 ];
|
|
588
|
+
* var y = [ 4, 5, 6 ];
|
|
589
|
+
* var z = [ 7, 8, 9 ];
|
|
590
|
+
*
|
|
591
|
+
* logEachMap( '%d', x, y, z, clbk );
|
|
592
|
+
* // e.g., => '12\n15\n18\n'
|
|
593
|
+
*/
|
|
594
|
+
declare function logEachMap( str: string, arg0: unknown, arg1: unknown, arg2: unknown, ...args: Array<unknown> ): void;
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
// EXPORTS //
|
|
598
|
+
|
|
599
|
+
export = logEachMap;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Insert array element values and the result of a callback function into a format string and print the result.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/console-log-each-map
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
28
|
+
*
|
|
29
|
+
* function add( x, y ) {
|
|
30
|
+
* return x + y;
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* var x = [ 1, 2, 3 ];
|
|
34
|
+
* var y = [ 4, 5, 6 ];
|
|
35
|
+
*
|
|
36
|
+
* logEachMap( '%d + %d = %d', x, y, add );
|
|
37
|
+
* // e.g., => '1 + 4 = 5\n2 + 5 = 7\n3 + 6 = 9\n'
|
|
38
|
+
*
|
|
39
|
+
* function multiply( x, y ) {
|
|
40
|
+
* return x * y;
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* var x = [ 0.5, 1.0, 1.5 ];
|
|
44
|
+
* var y = [ 0.5, 0.75, 1.0 ];
|
|
45
|
+
*
|
|
46
|
+
* logEachMap( '%0.2f * %0.2f = %0.2f', x, y, multiply );
|
|
47
|
+
* // e.g., => '0.50 * 0.50 = 0.25\n1.00 * 0.75 = 0.75\n1.50 * 1.00 = 1.50\n'
|
|
48
|
+
*
|
|
49
|
+
* function append( x, y ) {
|
|
50
|
+
* return x + y;
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* var x = [ 'foo', 'bar' ];
|
|
54
|
+
* var y = [ 'baz', 'beep' ];
|
|
55
|
+
*
|
|
56
|
+
* logEachMap( '%s+%s = %s', x, y, append );
|
|
57
|
+
* // e.g., => 'foo+baz = foobaz\nbar+beep = barbeep\n'
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
// MODULES //
|
|
61
|
+
|
|
62
|
+
var main = require( './main.js' );
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// EXPORTS //
|
|
66
|
+
|
|
67
|
+
module.exports = main;
|