@stdlib/utils-async-inmap-right 0.0.8 → 0.2.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 +0 -304
- package/NOTICE +1 -1
- package/README.md +36 -21
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +30 -36
- package/lib/factory.js +4 -4
- package/lib/index.js +3 -3
- package/lib/{inmap_right.js → main.js} +0 -1
- package/lib/validate.js +4 -3
- package/package.json +21 -18
- package/docs/repl.txt +0 -209
- package/docs/types/test.ts +0 -149
package/LICENSE
CHANGED
|
@@ -175,307 +175,3 @@
|
|
|
175
175
|
of your accepting any such warranty or additional liability.
|
|
176
176
|
|
|
177
177
|
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
182
|
-
|
|
183
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
184
|
-
obtaining a copy of the software and accompanying documentation covered by this
|
|
185
|
-
license (the "Software") to use, reproduce, display, distribute, execute, and
|
|
186
|
-
transmit the Software, and to prepare derivative works of the Software, and to
|
|
187
|
-
permit third-parties to whom the Software is furnished to do so, all subject to
|
|
188
|
-
the following:
|
|
189
|
-
|
|
190
|
-
The copyright notices in the Software and this entire statement, including the
|
|
191
|
-
above license grant, this restriction and the following disclaimer, must be
|
|
192
|
-
included in all copies of the Software, in whole or in part, and all derivative
|
|
193
|
-
works of the Software, unless such copies or derivative works are solely in the
|
|
194
|
-
form of machine-executable object code generated by a source language processor.
|
|
195
|
-
|
|
196
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
197
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
198
|
-
FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
199
|
-
COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
|
|
200
|
-
OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
201
|
-
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
DEPENDENCIES
|
|
207
|
-
|
|
208
|
-
The library links against the following external libraries, which have their own
|
|
209
|
-
licenses:
|
|
210
|
-
|
|
211
|
-
* OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
|
|
212
|
-
def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
|
|
213
|
-
|
|
214
|
-
Copyright (c) 2011-2014, The OpenBLAS Project
|
|
215
|
-
All rights reserved.
|
|
216
|
-
|
|
217
|
-
Redistribution and use in source and binary forms, with or without
|
|
218
|
-
modification, are permitted provided that the following conditions are
|
|
219
|
-
met:
|
|
220
|
-
|
|
221
|
-
1. Redistributions of source code must retain the above copyright
|
|
222
|
-
notice, this list of conditions and the following disclaimer.
|
|
223
|
-
|
|
224
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
225
|
-
notice, this list of conditions and the following disclaimer in
|
|
226
|
-
the documentation and/or other materials provided with the
|
|
227
|
-
distribution.
|
|
228
|
-
|
|
229
|
-
3. Neither the name of the OpenBLAS project nor the names of
|
|
230
|
-
its contributors may be used to endorse or promote products
|
|
231
|
-
derived from this software without specific prior written
|
|
232
|
-
permission.
|
|
233
|
-
|
|
234
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
235
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
236
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
237
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
238
|
-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
239
|
-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
240
|
-
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
241
|
-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
242
|
-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
243
|
-
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
* Electron <https://raw.githubusercontent.com/electron/electron/
|
|
247
|
-
c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
|
|
248
|
-
|
|
249
|
-
Copyright (c) 2013-2017 GitHub Inc.
|
|
250
|
-
|
|
251
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
252
|
-
a copy of this software and associated documentation files (the
|
|
253
|
-
"Software"), to deal in the Software without restriction, including
|
|
254
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
255
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
256
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
257
|
-
the following conditions:
|
|
258
|
-
|
|
259
|
-
The above copyright notice and this permission notice shall be
|
|
260
|
-
included in all copies or substantial portions of the Software.
|
|
261
|
-
|
|
262
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
263
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
264
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
265
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
266
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
267
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
268
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* Boost <http://www.boost.org/LICENSE_1_0.txt>
|
|
272
|
-
|
|
273
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
274
|
-
|
|
275
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
276
|
-
obtaining a copy of the software and accompanying documentation covered by
|
|
277
|
-
this license (the "Software") to use, reproduce, display, distribute,
|
|
278
|
-
execute, and transmit the Software, and to prepare derivative works of the
|
|
279
|
-
Software, and to permit third-parties to whom the Software is furnished to
|
|
280
|
-
do so, all subject to the following:
|
|
281
|
-
|
|
282
|
-
The copyright notices in the Software and this entire statement, including
|
|
283
|
-
the above license grant, this restriction and the following disclaimer,
|
|
284
|
-
must be included in all copies of the Software, in whole or in part, and
|
|
285
|
-
all derivative works of the Software, unless such copies or derivative
|
|
286
|
-
works are solely in the form of machine-executable object code generated by
|
|
287
|
-
a source language processor.
|
|
288
|
-
|
|
289
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
290
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
291
|
-
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
292
|
-
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
293
|
-
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
294
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
295
|
-
DEALINGS IN THE SOFTWARE.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* Cephes <http://www.netlib.org/cephes/readme>
|
|
299
|
-
|
|
300
|
-
Copyright (c) 1984-2000 Stephen L. Moshier
|
|
301
|
-
|
|
302
|
-
Some software in this archive may be from the book _Methods and Programs for
|
|
303
|
-
Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
|
|
304
|
-
or from the Cephes Mathematical Library, a commercial product. In either event,
|
|
305
|
-
it is copyrighted by the author. What you see here may be used freely but it
|
|
306
|
-
comes with no support or guarantee.
|
|
307
|
-
|
|
308
|
-
Stephen L. Moshier
|
|
309
|
-
moshier@na-net.ornl.gov
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
ATTRIBUTION
|
|
314
|
-
|
|
315
|
-
The library contains implementations from the following external libraries,
|
|
316
|
-
which have their own licenses:
|
|
317
|
-
|
|
318
|
-
* FreeBSD <https://svnweb.freebsd.org/>
|
|
319
|
-
|
|
320
|
-
Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
|
|
321
|
-
|
|
322
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
323
|
-
Permission to use, copy, modify, and distribute this
|
|
324
|
-
software is freely granted, provided that this notice
|
|
325
|
-
is preserved.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
* FDLIBM <http://www.netlib.org/fdlibm/>
|
|
329
|
-
|
|
330
|
-
Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
|
|
331
|
-
|
|
332
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
333
|
-
Permission to use, copy, modify, and distribute this
|
|
334
|
-
software is freely granted, provided that this notice
|
|
335
|
-
is preserved.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
* Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
|
|
339
|
-
|
|
340
|
-
Copyright (c) 2009 The Go Authors. All rights reserved.
|
|
341
|
-
|
|
342
|
-
Redistribution and use in source and binary forms, with or without
|
|
343
|
-
modification, are permitted provided that the following conditions are
|
|
344
|
-
met:
|
|
345
|
-
|
|
346
|
-
* Redistributions of source code must retain the above copyright
|
|
347
|
-
notice, this list of conditions and the following disclaimer.
|
|
348
|
-
* Redistributions in binary form must reproduce the above
|
|
349
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
350
|
-
in the documentation and/or other materials provided with the
|
|
351
|
-
distribution.
|
|
352
|
-
* Neither the name of Google Inc. nor the names of its
|
|
353
|
-
contributors may be used to endorse or promote products derived from
|
|
354
|
-
this software without specific prior written permission.
|
|
355
|
-
|
|
356
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
357
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
358
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
359
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
360
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
361
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
362
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
363
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
364
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
365
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
366
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
* SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
|
|
370
|
-
|
|
371
|
-
Public domain.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
* ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
|
|
375
|
-
|
|
376
|
-
Copyright JS Foundation and other contributors, https://js.foundation
|
|
377
|
-
|
|
378
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
379
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
380
|
-
in the Software without restriction, including without limitation the rights
|
|
381
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
382
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
383
|
-
furnished to do so, subject to the following conditions:
|
|
384
|
-
|
|
385
|
-
The above copyright notice and this permission notice shall be included in
|
|
386
|
-
all copies or substantial portions of the Software.
|
|
387
|
-
|
|
388
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
389
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
390
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
391
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
392
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
393
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
394
|
-
THE SOFTWARE.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
* StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
|
|
398
|
-
e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
|
|
399
|
-
|
|
400
|
-
Copyright (c) 2015: Dahua Lin.
|
|
401
|
-
|
|
402
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
403
|
-
a copy of this software and associated documentation files (the
|
|
404
|
-
"Software"), to deal in the Software without restriction, including
|
|
405
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
406
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
407
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
408
|
-
the following conditions:
|
|
409
|
-
|
|
410
|
-
The above copyright notice and this permission notice shall be
|
|
411
|
-
included in all copies or substantial portions of the Software.
|
|
412
|
-
|
|
413
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
414
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
415
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
416
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
417
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
418
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
419
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
* SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
|
|
423
|
-
SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
|
|
424
|
-
|
|
425
|
-
The MIT License (MIT)
|
|
426
|
-
|
|
427
|
-
Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
|
|
428
|
-
|
|
429
|
-
https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
|
|
430
|
-
|
|
431
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
432
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
433
|
-
in the Software without restriction, including without limitation the rights
|
|
434
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
435
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
436
|
-
furnished to do so, subject to the following conditions:
|
|
437
|
-
|
|
438
|
-
The above copyright notice and this permission notice shall be included in all
|
|
439
|
-
copies or substantial portions of the Software.
|
|
440
|
-
|
|
441
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
442
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
443
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
444
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
445
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
446
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
447
|
-
SOFTWARE.
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
* MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
|
|
451
|
-
mt19937ar.c>
|
|
452
|
-
|
|
453
|
-
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
|
454
|
-
All rights reserved.
|
|
455
|
-
|
|
456
|
-
Redistribution and use in source and binary forms, with or without
|
|
457
|
-
modification, are permitted provided that the following conditions
|
|
458
|
-
are met:
|
|
459
|
-
|
|
460
|
-
1. Redistributions of source code must retain the above copyright
|
|
461
|
-
notice, this list of conditions and the following disclaimer.
|
|
462
|
-
|
|
463
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
464
|
-
notice, this list of conditions and the following disclaimer in the
|
|
465
|
-
documentation and/or other materials provided with the distribution.
|
|
466
|
-
|
|
467
|
-
3. The names of its contributors may not be used to endorse or promote
|
|
468
|
-
products derived from this software without specific prior written
|
|
469
|
-
permission.
|
|
470
|
-
|
|
471
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
472
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
473
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
474
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
475
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
476
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
477
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
478
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
479
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
480
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
481
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2024 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# inmapRightAsync
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -138,9 +149,9 @@ inmapRightAsync( arr, fcn, done );
|
|
|
138
149
|
|
|
139
150
|
The function accepts the following `options`:
|
|
140
151
|
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
152
|
+
- **limit**: the maximum number of pending invocations at any one time. Default: `infinity`.
|
|
153
|
+
- **series**: boolean indicating whether to sequentially invoke `fcn` for each `collection` element. If `true`, the function sets `options.limit=1`. Default: `false`.
|
|
154
|
+
- **thisArg**: the execution context for `fcn`.
|
|
144
155
|
|
|
145
156
|
By default, all elements are processed concurrently, which means that the function does **not** guarantee completion order. To process each `collection` element sequentially, set the `series` option to `true`.
|
|
146
157
|
|
|
@@ -258,10 +269,10 @@ function done( error, collection ) {
|
|
|
258
269
|
|
|
259
270
|
When invoked, `fcn` is provided a maximum of four arguments:
|
|
260
271
|
|
|
261
|
-
-
|
|
262
|
-
-
|
|
263
|
-
-
|
|
264
|
-
-
|
|
272
|
+
- **value**: collection value.
|
|
273
|
+
- **index**: collection index.
|
|
274
|
+
- **collection**: the input `collection`.
|
|
275
|
+
- **next**: a callback which should be called once `fcn` has finished processing a collection `value`.
|
|
265
276
|
|
|
266
277
|
The actual number of provided arguments depends on function `length`. If `fcn` accepts two arguments, `fcn` is provided `value` and `next`. If `fcn` accepts three arguments, `fcn` is provided `value`, `index`, and `next`. For every other `fcn` signature, `fcn` is provided all four arguments.
|
|
267
278
|
|
|
@@ -302,7 +313,7 @@ inmapRightAsync( arr, fcn, done );
|
|
|
302
313
|
|
|
303
314
|
#### inmapRightAsync.factory( \[options,] fcn )
|
|
304
315
|
|
|
305
|
-
Returns a
|
|
316
|
+
Returns a function which invokes a function once for each element in a `collection`, iterating from right to left.
|
|
306
317
|
|
|
307
318
|
```javascript
|
|
308
319
|
function fcn( value, index, next ) {
|
|
@@ -430,9 +441,9 @@ inmapRightAsync( files, read, done );
|
|
|
430
441
|
|
|
431
442
|
## See Also
|
|
432
443
|
|
|
433
|
-
- <span class="package-name">[`@stdlib/utils
|
|
434
|
-
- <span class="package-name">[`@stdlib/utils
|
|
435
|
-
- <span class="package-name">[`@stdlib/utils
|
|
444
|
+
- <span class="package-name">[`@stdlib/utils-async/for-each-right`][@stdlib/utils/async/for-each-right]</span><span class="delimiter">: </span><span class="description">invoke a function once for each element in a collection, iterating from right to left.</span>
|
|
445
|
+
- <span class="package-name">[`@stdlib/utils-async/inmap`][@stdlib/utils/async/inmap]</span><span class="delimiter">: </span><span class="description">invoke a function for each element in a collection and update the collection in-place.</span>
|
|
446
|
+
- <span class="package-name">[`@stdlib/utils-inmap-right`][@stdlib/utils/inmap-right]</span><span class="delimiter">: </span><span class="description">invoke a function for each element in a collection and update the collection in-place, iterating from right to left.</span>
|
|
436
447
|
|
|
437
448
|
</section>
|
|
438
449
|
|
|
@@ -464,7 +475,7 @@ See [LICENSE][stdlib-license].
|
|
|
464
475
|
|
|
465
476
|
## Copyright
|
|
466
477
|
|
|
467
|
-
Copyright © 2016-
|
|
478
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
468
479
|
|
|
469
480
|
</section>
|
|
470
481
|
|
|
@@ -477,8 +488,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
477
488
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/utils-async-inmap-right.svg
|
|
478
489
|
[npm-url]: https://npmjs.org/package/@stdlib/utils-async-inmap-right
|
|
479
490
|
|
|
480
|
-
[test-image]: https://github.com/stdlib-js/utils-async-inmap-right/actions/workflows/test.yml/badge.svg
|
|
481
|
-
[test-url]: https://github.com/stdlib-js/utils-async-inmap-right/actions/workflows/test.yml
|
|
491
|
+
[test-image]: https://github.com/stdlib-js/utils-async-inmap-right/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
492
|
+
[test-url]: https://github.com/stdlib-js/utils-async-inmap-right/actions/workflows/test.yml?query=branch:v0.2.0
|
|
482
493
|
|
|
483
494
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-async-inmap-right/main.svg
|
|
484
495
|
[coverage-url]: https://codecov.io/github/stdlib-js/utils-async-inmap-right?branch=main
|
|
@@ -490,19 +501,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
490
501
|
|
|
491
502
|
-->
|
|
492
503
|
|
|
504
|
+
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
505
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
506
|
+
|
|
507
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
508
|
+
|
|
509
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
510
|
+
|
|
493
511
|
[umd]: https://github.com/umdjs/umd
|
|
494
512
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
495
513
|
|
|
496
514
|
[deno-url]: https://github.com/stdlib-js/utils-async-inmap-right/tree/deno
|
|
515
|
+
[deno-readme]: https://github.com/stdlib-js/utils-async-inmap-right/blob/deno/README.md
|
|
497
516
|
[umd-url]: https://github.com/stdlib-js/utils-async-inmap-right/tree/umd
|
|
517
|
+
[umd-readme]: https://github.com/stdlib-js/utils-async-inmap-right/blob/umd/README.md
|
|
498
518
|
[esm-url]: https://github.com/stdlib-js/utils-async-inmap-right/tree/esm
|
|
499
|
-
|
|
500
|
-
[
|
|
501
|
-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
502
|
-
|
|
503
|
-
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
504
|
-
|
|
505
|
-
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
519
|
+
[esm-readme]: https://github.com/stdlib-js/utils-async-inmap-right/blob/esm/README.md
|
|
520
|
+
[branches-url]: https://github.com/stdlib-js/utils-async-inmap-right/blob/main/branches.md
|
|
506
521
|
|
|
507
522
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/utils-async-inmap-right/main/LICENSE
|
|
508
523
|
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";var g=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var p=g(function(U,A){
|
|
2
|
+
var N=require('@stdlib/assert-is-plain-object/dist'),c=require('@stdlib/assert-has-own-property/dist'),R=require('@stdlib/assert-is-boolean/dist').isPrimitive,k=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,o=require('@stdlib/error-tools-fmtprodmsg/dist');function I(e,r){return N(r)?(c(r,"thisArg")&&(e.thisArg=r.thisArg),c(r,"series")&&(e.series=r.series,!R(e.series))?new TypeError(o('1RJ2o',"series",e.series)):c(r,"limit")&&(e.limit=r.limit,!k(e.limit))?new TypeError(o('1RJ3P',"limit",e.limit)):null):new TypeError(o('1RJ2V',r));}A.exports=I
|
|
3
|
+
});var E=g(function(W,x){
|
|
4
|
+
var L=require("debug"),l=L("inmap-right-async:limit");function B(e,r,i,s){var n,v,u,t,m,f;if(t=e.length,l("Collection length: %d",t),t===0)return l("Finished processing a collection."),s();for(t<r.limit?u=t:u=r.limit,l("Concurrency limit: %d",u),l("Number of arguments: %d",i.length),n=0,m=t,f=0;f<u;f++)m>0&&y();function y(){var a;m-=1,a=m,l("Collection element %d: %s.",a,JSON.stringify(e[a])),i.length===2?i.call(r.thisArg,e[a],h):i.length===3?i.call(r.thisArg,e[a],a,h):i.call(r.thisArg,e[a],a,e,h);function h(w,j){if(!v){if(w)return v=!0,b(w);e[a]=j,b()}}}function b(a){if(a)return l("Encountered an error: %s",a.message),s(a);if(n+=1,l("Processed %d of %d collection elements.",n,t),m>0)return y();if(n===t)return l("Finished processing a collection."),s()}}x.exports=B
|
|
5
|
+
});var q=g(function(X,P){
|
|
6
|
+
var O=require('@stdlib/assert-is-function/dist'),J=require('@stdlib/assert-is-collection/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),S=require('@stdlib/constants-float64-pinf/dist'),z=p(),D=E();function G(e,r){var i,s,n;if(i={},arguments.length>1){if(s=z(i,e),s)throw s;n=r}else n=e;if(!O(n))throw new TypeError(d('1RJ3q',n));return i.series?i.limit=1:i.limit||(i.limit=S),v;function v(u,t){if(!J(u))throw new TypeError(d('1RJAh',u));if(!O(t))throw new TypeError(d('1RJ3q',t));return D(u,i,n,m);function m(f){if(f)return t(f,u);t(null,u)}}}P.exports=G
|
|
7
|
+
});var C=g(function(Y,F){
|
|
8
|
+
var T=q();function H(e,r,i,s){if(arguments.length<4)return T(r)(e,i);T(r,i)(e,s)}F.exports=H
|
|
9
|
+
});var K=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),V=C(),M=q();K(V,"factory",M);module.exports=V;
|
|
10
|
+
/** @license Apache-2.0 */
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/validate.js", "../lib/limit.js", "../lib/factory.js", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'thisArg': {},\n* 'series': false,\n* 'limit': 10\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'thisArg' ) ) {\n\t\topts.thisArg = options.thisArg;\n\t}\n\tif ( hasOwnProp( options, 'series' ) ) {\n\t\topts.series = options.series;\n\t\tif ( !isBoolean( opts.series ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'series', opts.series ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'limit' ) ) {\n\t\topts.limit = options.limit;\n\t\tif ( !isPositiveInteger( opts.limit ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'limit', opts.limit ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// VARIABLES //\n\nvar debug = logger( 'inmap-right-async:limit' );\n\n\n// MAIN //\n\n/**\n* Invokes a function once for each element in a collection, limiting the number of concurrently pending functions and iterating from right to left, and updates a collection in-place.\n*\n* @private\n* @param {Collection} collection - input collection\n* @param {Options} opts - function options\n* @param {*} [opts.thisArg] - execution context\n* @param {PositiveInteger} [opts.limit] - maximum number of pending function invocations\n* @param {Function} fcn - function to invoke\n* @param {Callback} done - function to invoke upon completion or upon encountering an error\n* @returns {void}\n*/\nfunction limit( collection, opts, fcn, done ) {\n\tvar count;\n\tvar flg;\n\tvar lim;\n\tvar len;\n\tvar idx;\n\tvar i;\n\n\tlen = collection.length;\n\tdebug( 'Collection length: %d', len );\n\n\tif ( len === 0 ) {\n\t\tdebug( 'Finished processing a collection.' );\n\t\treturn done();\n\t}\n\tif ( len < opts.limit ) {\n\t\tlim = len;\n\t} else {\n\t\tlim = opts.limit;\n\t}\n\tdebug( 'Concurrency limit: %d', lim );\n\tdebug( 'Number of arguments: %d', fcn.length );\n\n\tcount = 0;\n\tidx = len;\n\tfor ( i = 0; i < lim; i++ ) {\n\t\t// This guard is necessary to protect against synchronous functions which exhaust all collection elements...\n\t\tif ( idx > 0 ) {\n\t\t\tnext(); // eslint-disable-line node/callback-return\n\t\t}\n\t}\n\t/**\n\t* Callback to invoke a provided function for the next element in a collection.\n\t*\n\t* @private\n\t*/\n\tfunction next() {\n\t\tvar j;\n\t\tidx -= 1;\n\t\tj = idx;\n\t\tdebug( 'Collection element %d: %s.', j, JSON.stringify( collection[ j ] ) );\n\t\tif ( fcn.length === 2 ) {\n\t\t\tfcn.call( opts.thisArg, collection[ j ], cb );\n\t\t} else if ( fcn.length === 3 ) {\n\t\t\tfcn.call( opts.thisArg, collection[ j ], j, cb );\n\t\t} else {\n\t\t\tfcn.call( opts.thisArg, collection[ j ], j, collection, cb );\n\t\t}\n\t\t/**\n\t\t* Callback invoked once a provided function finishes processing a collection element.\n\t\t*\n\t\t* @private\n\t\t* @param {*} [error] - error\n\t\t* @param {*} [result] - result\n\t\t* @returns {void}\n\t\t*/\n\t\tfunction cb( error, result ) {\n\t\t\tif ( flg ) {\n\t\t\t\t// Prevent further processing of collection elements:\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( error ) {\n\t\t\t\tflg = true;\n\t\t\t\treturn clbk( error );\n\t\t\t}\n\t\t\tcollection[ j ] = result;\n\t\t\tclbk();\n\t\t}\n\t}\n\n\t/**\n\t* Callback invoked once ready to process the next collection element.\n\t*\n\t* @private\n\t* @param {*} [error] - error\n\t* @returns {void}\n\t*/\n\tfunction clbk( error ) {\n\t\tif ( error ) {\n\t\t\tdebug( 'Encountered an error: %s', error.message );\n\t\t\treturn done( error );\n\t\t}\n\t\tcount += 1;\n\t\tdebug( 'Processed %d of %d collection elements.', count, len );\n\t\tif ( idx > 0 ) {\n\t\t\treturn next();\n\t\t}\n\t\tif ( count === len ) {\n\t\t\tdebug( 'Finished processing a collection.' );\n\t\t\treturn done();\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = limit;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\nvar validate = require( './validate.js' );\nvar limit = require( './limit.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function to invoke a function once for each element in a collection and to update the collection in-place, iterating from right to left.\n*\n* ## Notes\n*\n* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.\n* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).\n*\n* @param {Options} [options] - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series=false] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection\n* @param {Function} fcn - function to invoke for each element in a collection\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} last argument must be a function\n* @returns {Function} function which invokes the provided function once for each element in a collection\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error, data ) {\n* if ( error ) {\n* return next( error );\n* }\n* next( null, data );\n* }\n* }\n*\n* var opts = {\n* 'series': true\n* };\n*\n* // Create a `inmapRightAsync` function which invokes `read` for each collection element sequentially:\n* var inmapRightAsync = factory( opts, read );\n*\n* // Create a collection over which to iterate:\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* // Define a callback which handles errors:\n* function done( error, results ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( results );\n* }\n*\n* // Run `read` for each element in `files`:\n* inmapRightAsync( files, done );\n*/\nfunction factory( options, fcn ) {\n\tvar opts;\n\tvar err;\n\tvar f;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\tf = fcn;\n\t} else {\n\t\tf = options;\n\t}\n\tif ( !isFunction( f ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );\n\t}\n\tif ( opts.series ) {\n\t\topts.limit = 1;\n\t} else if ( !opts.limit ) {\n\t\topts.limit = PINF;\n\t}\n\treturn inmapRightAsync;\n\n\t/**\n\t* Invokes a function for each element in a collection and updates a collection in-place, iterating from right to left.\n\t*\n\t* @private\n\t* @param {Collection} collection - input collection\n\t* @param {Callback} done - function to invoke upon completion\n\t* @throws {TypeError} first argument must be a collection\n\t* @throws {TypeError} last argument must be a function\n\t* @returns {void}\n\t*/\n\tfunction inmapRightAsync( collection, done ) {\n\t\tif ( !isCollection( collection ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );\n\t\t}\n\t\tif ( !isFunction( done ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );\n\t\t}\n\t\treturn limit( collection, opts, f, clbk );\n\n\t\t/**\n\t\t* Callback invoked upon completion.\n\t\t*\n\t\t* @private\n\t\t* @param {*} [error] - error\n\t\t* @returns {void}\n\t\t*/\n\t\tfunction clbk( error ) {\n\t\t\tif ( error ) {\n\t\t\t\treturn done( error, collection );\n\t\t\t}\n\t\t\tdone( null, collection );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\n/**\n* Invokes a function once for each element in a collection and updates a collection in-place, iterating from right to left.\n*\n* ## Notes\n*\n* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.\n* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).\n*\n* @param {Collection} collection - input collection\n* @param {Options} [options] - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series=false] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection\n* @param {Function} fcn - function to invoke for each element in a collection\n* @param {Callback} done - function to invoke upon completion\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} second-to-last argument must be a function\n* @throws {TypeError} last argument must be a function\n* @returns {void}\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n*\n* function done( error, results ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( results );\n* }\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error, data ) {\n* if ( error ) {\n* return next( error );\n* }\n* next( null, data );\n* }\n* }\n*\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* inmapRightAsync( files, read, done );\n*/\nfunction inmapRightAsync( collection, options, fcn, done ) {\n\tif ( arguments.length < 4 ) {\n\t\treturn factory( options )( collection, fcn );\n\t}\n\tfactory( options, fcn )( collection, done );\n}\n\n\n// EXPORTS //\n\nmodule.exports = inmapRightAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function once for each element in a collection and update a collection in-place, iterating from right to left.\n*\n* @module @stdlib/utils-async-inmap-right\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n* var inmapRightAsync = require( '@stdlib/utils-async-inmap-right' );\n*\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* function done( error, results ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( results );\n* }\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error, data ) {\n* if ( error ) {\n* error = new Error( 'unable to read file: '+file );\n* return next( error );\n* }\n* next( null, data );\n* }\n* }\n*\n* inmapRightAsync( files, read, done );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA4B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMP,EAAUO,CAAQ,GAGnBN,EAAYM,EAAS,SAAU,IACnCD,EAAK,QAAUC,EAAQ,SAEnBN,EAAYM,EAAS,QAAS,IAClCD,EAAK,OAASC,EAAQ,OACjB,CAACL,EAAWI,EAAK,MAAO,GACrB,IAAI,UAAWF,EAAQ,+DAAgE,SAAUE,EAAK,MAAO,CAAE,EAGnHL,EAAYM,EAAS,OAAQ,IACjCD,EAAK,MAAQC,EAAQ,MAChB,CAACJ,EAAmBG,EAAK,KAAM,GAC5B,IAAI,UAAWF,EAAQ,wEAAyE,QAASE,EAAK,KAAM,CAAE,EAGxH,MAjBC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAkBhH,CAKAR,EAAO,QAAUM,IC/EjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAK1BC,EAAQD,EAAQ,yBAA0B,EAiB9C,SAASE,EAAOC,EAAYC,EAAMC,EAAKC,EAAO,CAC7C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAKJ,GAHAF,EAAMP,EAAW,OACjBF,EAAO,wBAAyBS,CAAI,EAE/BA,IAAQ,EACZ,OAAAT,EAAO,mCAAoC,EACpCK,EAAK,EAYb,IAVKI,EAAMN,EAAK,MACfK,EAAMC,EAEND,EAAML,EAAK,MAEZH,EAAO,wBAAyBQ,CAAI,EACpCR,EAAO,0BAA2BI,EAAI,MAAO,EAE7CE,EAAQ,EACRI,EAAMD,EACAE,EAAI,EAAGA,EAAIH,EAAKG,IAEhBD,EAAM,GACVE,EAAK,EAQP,SAASA,GAAO,CACf,IAAIC,EACJH,GAAO,EACPG,EAAIH,EACJV,EAAO,6BAA8Ba,EAAG,KAAK,UAAWX,EAAYW,CAAE,CAAE,CAAE,EACrET,EAAI,SAAW,EACnBA,EAAI,KAAMD,EAAK,QAASD,EAAYW,CAAE,EAAGC,CAAG,EACjCV,EAAI,SAAW,EAC1BA,EAAI,KAAMD,EAAK,QAASD,EAAYW,CAAE,EAAGA,EAAGC,CAAG,EAE/CV,EAAI,KAAMD,EAAK,QAASD,EAAYW,CAAE,EAAGA,EAAGX,EAAYY,CAAG,EAU5D,SAASA,EAAIC,EAAOC,EAAS,CAC5B,GAAK,CAAAT,EAIL,IAAKQ,EACJ,OAAAR,EAAM,GACCU,EAAMF,CAAM,EAEpBb,EAAYW,CAAE,EAAIG,EAClBC,EAAK,EACN,CACD,CASA,SAASA,EAAMF,EAAQ,CACtB,GAAKA,EACJ,OAAAf,EAAO,2BAA4Be,EAAM,OAAQ,EAC1CV,EAAMU,CAAM,EAIpB,GAFAT,GAAS,EACTN,EAAO,0CAA2CM,EAAOG,CAAI,EACxDC,EAAM,EACV,OAAOE,EAAK,EAEb,GAAKN,IAAUG,EACd,OAAAT,EAAO,mCAAoC,EACpCK,EAAK,CAEd,CACD,CAKAP,EAAO,QAAUG,IC7IjB,IAAAiB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,gCAAiC,EACjDC,EAAW,IACXC,EAAQ,IAgEZ,SAASC,EAASC,EAASC,EAAM,CAChC,IAAIC,EACAC,EACAC,EAGJ,GADAF,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAC,EAAMN,EAAUK,EAAMF,CAAQ,EACzBG,EACJ,MAAMA,EAEPC,EAAIH,CACL,MACCG,EAAIJ,EAEL,GAAK,CAACP,EAAYW,CAAE,EACnB,MAAM,IAAI,UAAWT,EAAQ,mEAAoES,CAAE,CAAE,EAEtG,OAAKF,EAAK,OACTA,EAAK,MAAQ,EACDA,EAAK,QACjBA,EAAK,MAAQN,GAEPS,EAYP,SAASA,EAAiBC,EAAYC,EAAO,CAC5C,GAAK,CAACb,EAAcY,CAAW,EAC9B,MAAM,IAAI,UAAWX,EAAQ,sEAAuEW,CAAW,CAAE,EAElH,GAAK,CAACb,EAAYc,CAAK,EACtB,MAAM,IAAI,UAAWZ,EAAQ,mEAAoEY,CAAK,CAAE,EAEzG,OAAOT,EAAOQ,EAAYJ,EAAME,EAAGI,CAAK,EASxC,SAASA,EAAMC,EAAQ,CACtB,GAAKA,EACJ,OAAOF,EAAME,EAAOH,CAAW,EAEhCC,EAAM,KAAMD,CAAW,CACxB,CACD,CACD,CAKAd,EAAO,QAAUO,IC1JjB,IAAAW,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,IA0Dd,SAASC,EAAiBC,EAAYC,EAASC,EAAKC,EAAO,CAC1D,GAAK,UAAU,OAAS,EACvB,OAAOL,EAASG,CAAQ,EAAGD,EAAYE,CAAI,EAE5CJ,EAASG,EAASC,CAAI,EAAGF,EAAYG,CAAK,CAC3C,CAKAN,EAAO,QAAUE,IC7BjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
|
|
6
|
+
"names": ["require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isPositiveInteger", "format", "validate", "opts", "options", "require_limit", "__commonJSMin", "exports", "module", "logger", "debug", "limit", "collection", "opts", "fcn", "done", "count", "flg", "lim", "len", "idx", "i", "next", "j", "cb", "error", "result", "clbk", "require_factory", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "format", "PINF", "validate", "limit", "factory", "options", "fcn", "opts", "err", "f", "inmapRightAsync", "collection", "done", "clbk", "error", "require_main", "__commonJSMin", "exports", "module", "factory", "inmapRightAsync", "collection", "options", "fcn", "done", "setReadOnly", "main", "factory"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,43 +16,43 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/// <reference types="@stdlib/types"/>
|
|
22
22
|
|
|
23
|
-
import { Collection } from '@stdlib/types/
|
|
23
|
+
import { Collection } from '@stdlib/types/array';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Interface defining function options.
|
|
27
27
|
*/
|
|
28
|
-
interface Options {
|
|
28
|
+
interface Options<T, U, V> {
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Execution context.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
thisArg?: ThisParameterType<Fcn<T, U, V>>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* The maximum number of pending invocations at any one time.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
limit?: number;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Boolean indicating whether to sequentially invoke the provided function for each `collection` element. If `true`, the function sets `options.limit=1`. Default: false.
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
series?: boolean;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Callback invoked either upon processing all collection elements or upon encountering an error.
|
|
47
47
|
*/
|
|
48
|
-
type
|
|
48
|
+
type Nullary = () => void;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Callback invoked either upon processing all collection elements or upon encountering an error.
|
|
52
52
|
*
|
|
53
53
|
* @param error - error argument
|
|
54
54
|
*/
|
|
55
|
-
type
|
|
55
|
+
type Unary = ( error: Error ) => void;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Callback invoked either upon processing all collection elements or upon encountering an error.
|
|
@@ -60,7 +60,7 @@ type DoneUnary = ( error: Error ) => void;
|
|
|
60
60
|
* @param error - error argument
|
|
61
61
|
* @param collection - updated input collection
|
|
62
62
|
*/
|
|
63
|
-
type
|
|
63
|
+
type Binary<U> = ( error: Error, collection: Collection<U> ) => void;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Callback invoked either upon processing all collection elements or upon encountering an error.
|
|
@@ -68,15 +68,14 @@ type DoneBinary = ( error: Error, collection: Collection ) => void;
|
|
|
68
68
|
* @param error - error argument
|
|
69
69
|
* @param collection - updated input collection
|
|
70
70
|
*/
|
|
71
|
-
type
|
|
71
|
+
type Callback<U> = Nullary | Unary | Binary<U>;
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Callback function.
|
|
75
75
|
*
|
|
76
76
|
* @param error - error argument
|
|
77
|
-
* @param result - value used to update the collection
|
|
78
77
|
*/
|
|
79
|
-
type
|
|
78
|
+
type UnaryNext = ( error: Error ) => void;
|
|
80
79
|
|
|
81
80
|
/**
|
|
82
81
|
* Callback function.
|
|
@@ -84,7 +83,7 @@ type Unary = ( error: Error ) => void;
|
|
|
84
83
|
* @param error - error argument
|
|
85
84
|
* @param result - value used to update the collection
|
|
86
85
|
*/
|
|
87
|
-
type
|
|
86
|
+
type BinaryNext<U> = ( error: Error | null, result: U ) => void;
|
|
88
87
|
|
|
89
88
|
/**
|
|
90
89
|
* Callback function.
|
|
@@ -92,7 +91,7 @@ type Binary = ( error: Error | null, result: any ) => void;
|
|
|
92
91
|
* @param error - error argument
|
|
93
92
|
* @param result - value used to update the collection
|
|
94
93
|
*/
|
|
95
|
-
type
|
|
94
|
+
type Next<U> = UnaryNext | BinaryNext<U>;
|
|
96
95
|
|
|
97
96
|
/**
|
|
98
97
|
* Function invoked for each element in a collection.
|
|
@@ -100,7 +99,7 @@ type Callback = Unary | Binary;
|
|
|
100
99
|
* @param value - collection value
|
|
101
100
|
* @param next - a callback to be invoked after processing a collection `value`
|
|
102
101
|
*/
|
|
103
|
-
type BinaryFcn = ( value:
|
|
102
|
+
type BinaryFcn<T, U, V> = ( this: V, value: T, next: Next<U> ) => void;
|
|
104
103
|
|
|
105
104
|
/**
|
|
106
105
|
* Function invoked for each element in a collection.
|
|
@@ -109,7 +108,7 @@ type BinaryFcn = ( value: any, next: Callback ) => void;
|
|
|
109
108
|
* @param index - collection index
|
|
110
109
|
* @param next - a callback to be invoked after processing a collection `value`
|
|
111
110
|
*/
|
|
112
|
-
type TernaryFcn = ( value:
|
|
111
|
+
type TernaryFcn<T, U, V> = ( this: V, value: T, index: number, next: Next<U> ) => void;
|
|
113
112
|
|
|
114
113
|
/**
|
|
115
114
|
* Function invoked for each element in a collection.
|
|
@@ -119,7 +118,7 @@ type TernaryFcn = ( value: any, index: number, next: Callback ) => void;
|
|
|
119
118
|
* @param collection - input collection
|
|
120
119
|
* @param next - a callback to be invoked after processing a collection `value`
|
|
121
120
|
*/
|
|
122
|
-
type QuaternaryFcn = ( value:
|
|
121
|
+
type QuaternaryFcn<T, U, V> = ( this: V, value: T, index: number, collection: Collection<U>, next: Next<U> ) => void;
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
124
|
* Function invoked for each element in a collection.
|
|
@@ -129,7 +128,7 @@ type QuaternaryFcn = ( value: any, index: number, collection: Collection, next:
|
|
|
129
128
|
* @param collection - input collection
|
|
130
129
|
* @param next - a callback to be invoked after processing a collection `value`
|
|
131
130
|
*/
|
|
132
|
-
type Fcn = BinaryFcn | TernaryFcn | QuaternaryFcn
|
|
131
|
+
type Fcn<T, U, V> = BinaryFcn<T, U, V> | TernaryFcn<T, U, V> | QuaternaryFcn<T, U, V>;
|
|
133
132
|
|
|
134
133
|
/**
|
|
135
134
|
* Invokes the provided function for each element in a collection and updates a collection in-place.
|
|
@@ -137,7 +136,7 @@ type Fcn = BinaryFcn | TernaryFcn | QuaternaryFcn;
|
|
|
137
136
|
* @param collection - input collection
|
|
138
137
|
* @param done - function to invoke upon completion
|
|
139
138
|
*/
|
|
140
|
-
type FactoryFunction = ( collection: Collection
|
|
139
|
+
type FactoryFunction<T, U> = ( collection: Collection<T>, done: Callback<U> ) => void;
|
|
141
140
|
|
|
142
141
|
/**
|
|
143
142
|
* Interface for `inmapRightAsync`.
|
|
@@ -151,7 +150,6 @@ interface InMapRightAsync {
|
|
|
151
150
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
152
151
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
153
152
|
*
|
|
154
|
-
*
|
|
155
153
|
* @param collection - input collection
|
|
156
154
|
* @param options - function options
|
|
157
155
|
* @param options.thisArg - execution context
|
|
@@ -162,7 +160,7 @@ interface InMapRightAsync {
|
|
|
162
160
|
* @throws must provide valid options
|
|
163
161
|
*
|
|
164
162
|
* @example
|
|
165
|
-
* var readFile = require(
|
|
163
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
166
164
|
*
|
|
167
165
|
* function done( error, results ) {
|
|
168
166
|
* if ( error ) {
|
|
@@ -192,7 +190,7 @@ interface InMapRightAsync {
|
|
|
192
190
|
*
|
|
193
191
|
* inmapRightAsync( files, {}, read, done );
|
|
194
192
|
*/
|
|
195
|
-
( collection: Collection
|
|
193
|
+
<T = unknown, U = unknown, V = unknown>( collection: Collection<T>, options: Options<T, U, V>, fcn: Fcn<T, U, V>, done: Callback<U> ): void;
|
|
196
194
|
|
|
197
195
|
/**
|
|
198
196
|
* Invokes a function once for each element in a collection and updates a collection in-place.
|
|
@@ -202,13 +200,12 @@ interface InMapRightAsync {
|
|
|
202
200
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
203
201
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
204
202
|
*
|
|
205
|
-
*
|
|
206
203
|
* @param collection - input collection
|
|
207
204
|
* @param fcn - function to invoke for each element in a collection
|
|
208
205
|
* @param done - function to invoke upon completion
|
|
209
206
|
*
|
|
210
207
|
* @example
|
|
211
|
-
* var readFile = require(
|
|
208
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
212
209
|
*
|
|
213
210
|
* function done( error, results ) {
|
|
214
211
|
* if ( error ) {
|
|
@@ -238,7 +235,7 @@ interface InMapRightAsync {
|
|
|
238
235
|
*
|
|
239
236
|
* inmapRightAsync( files, read, done );
|
|
240
237
|
*/
|
|
241
|
-
( collection: Collection
|
|
238
|
+
<T = unknown, U = unknown, V = unknown>( collection: Collection<T>, fcn: Fcn<T, U, V>, done: Callback<U> ): void;
|
|
242
239
|
|
|
243
240
|
/**
|
|
244
241
|
* Returns a function to invoke a function once for each element in a collection and to update the collection in-place.
|
|
@@ -248,7 +245,6 @@ interface InMapRightAsync {
|
|
|
248
245
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
249
246
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
250
247
|
*
|
|
251
|
-
*
|
|
252
248
|
* @param options - function options
|
|
253
249
|
* @param options.thisArg - execution context
|
|
254
250
|
* @param options.limit - maximum number of pending invocations at any one time
|
|
@@ -258,7 +254,7 @@ interface InMapRightAsync {
|
|
|
258
254
|
* @returns function which invokes the provided function once for each element in a collection
|
|
259
255
|
*
|
|
260
256
|
* @example
|
|
261
|
-
* var readFile = require(
|
|
257
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
262
258
|
*
|
|
263
259
|
* function read( file, next ) {
|
|
264
260
|
* var opts = {
|
|
@@ -298,7 +294,7 @@ interface InMapRightAsync {
|
|
|
298
294
|
* // Run `read` for each element in `files`:
|
|
299
295
|
* inmapRightAsync( files, done );
|
|
300
296
|
*/
|
|
301
|
-
factory( options: Options, fcn: Fcn ): FactoryFunction
|
|
297
|
+
factory<T = unknown, U = unknown, V = unknown>( options: Options<T, U, V>, fcn: Fcn<T, U, V> ): FactoryFunction<T, U>;
|
|
302
298
|
|
|
303
299
|
/**
|
|
304
300
|
* Returns a function to invoke a function once for each element in a collection and to update the collection in-place.
|
|
@@ -308,13 +304,12 @@ interface InMapRightAsync {
|
|
|
308
304
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
309
305
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
310
306
|
*
|
|
311
|
-
*
|
|
312
307
|
* @param fcn - function to invoke for each element in a collection
|
|
313
308
|
* @throws must provide valid options
|
|
314
309
|
* @returns function which invokes the provided function once for each element in a collection
|
|
315
310
|
*
|
|
316
311
|
* @example
|
|
317
|
-
* var readFile = require(
|
|
312
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
318
313
|
*
|
|
319
314
|
* function read( file, next ) {
|
|
320
315
|
* var opts = {
|
|
@@ -350,7 +345,7 @@ interface InMapRightAsync {
|
|
|
350
345
|
* // Run `read` for each element in `files`:
|
|
351
346
|
* inmapRightAsync( files, done );
|
|
352
347
|
*/
|
|
353
|
-
factory( fcn: Fcn ): FactoryFunction
|
|
348
|
+
factory<T = unknown, U = unknown, V = unknown>( fcn: Fcn<T, U, V> ): FactoryFunction<T, U>;
|
|
354
349
|
}
|
|
355
350
|
|
|
356
351
|
/**
|
|
@@ -361,7 +356,6 @@ interface InMapRightAsync {
|
|
|
361
356
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
362
357
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
363
358
|
*
|
|
364
|
-
*
|
|
365
359
|
* @param collection - input collection
|
|
366
360
|
* @param options - function options
|
|
367
361
|
* @param options.thisArg - execution context
|
|
@@ -372,7 +366,7 @@ interface InMapRightAsync {
|
|
|
372
366
|
* @throws must provide valid options
|
|
373
367
|
*
|
|
374
368
|
* @example
|
|
375
|
-
* var readFile = require(
|
|
369
|
+
* var readFile = require( '@stdlib/fs-read-file' );
|
|
376
370
|
*
|
|
377
371
|
* function done( error, results ) {
|
|
378
372
|
* if ( error ) {
|
package/lib/factory.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
var isFunction = require( '@stdlib/assert-is-function' );
|
|
24
24
|
var isCollection = require( '@stdlib/assert-is-collection' );
|
|
25
|
+
var format = require( '@stdlib/string-format' );
|
|
25
26
|
var PINF = require( '@stdlib/constants-float64-pinf' );
|
|
26
27
|
var validate = require( './validate.js' );
|
|
27
28
|
var limit = require( './limit.js' );
|
|
@@ -37,7 +38,6 @@ var limit = require( './limit.js' );
|
|
|
37
38
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
38
39
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
39
40
|
*
|
|
40
|
-
*
|
|
41
41
|
* @param {Options} [options] - function options
|
|
42
42
|
* @param {*} [options.thisArg] - execution context
|
|
43
43
|
* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time
|
|
@@ -105,7 +105,7 @@ function factory( options, fcn ) {
|
|
|
105
105
|
f = options;
|
|
106
106
|
}
|
|
107
107
|
if ( !isFunction( f ) ) {
|
|
108
|
-
throw new TypeError( 'invalid argument. Last argument must be a function. Value:
|
|
108
|
+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );
|
|
109
109
|
}
|
|
110
110
|
if ( opts.series ) {
|
|
111
111
|
opts.limit = 1;
|
|
@@ -126,10 +126,10 @@ function factory( options, fcn ) {
|
|
|
126
126
|
*/
|
|
127
127
|
function inmapRightAsync( collection, done ) {
|
|
128
128
|
if ( !isCollection( collection ) ) {
|
|
129
|
-
throw new TypeError( 'invalid argument. First argument must be a collection. Value:
|
|
129
|
+
throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );
|
|
130
130
|
}
|
|
131
131
|
if ( !isFunction( done ) ) {
|
|
132
|
-
throw new TypeError( 'invalid argument. Last argument must be a function. Value:
|
|
132
|
+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );
|
|
133
133
|
}
|
|
134
134
|
return limit( collection, opts, f, clbk );
|
|
135
135
|
|
package/lib/index.js
CHANGED
|
@@ -60,15 +60,15 @@
|
|
|
60
60
|
// MODULES //
|
|
61
61
|
|
|
62
62
|
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
63
|
-
var
|
|
63
|
+
var main = require( './main.js' );
|
|
64
64
|
var factory = require( './factory.js' );
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
// MAIN //
|
|
68
68
|
|
|
69
|
-
setReadOnly(
|
|
69
|
+
setReadOnly( main, 'factory', factory );
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
// EXPORTS //
|
|
73
73
|
|
|
74
|
-
module.exports =
|
|
74
|
+
module.exports = main;
|
|
@@ -33,7 +33,6 @@ var factory = require( './factory.js' );
|
|
|
33
33
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
34
34
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
36
|
* @param {Collection} collection - input collection
|
|
38
37
|
* @param {Options} [options] - function options
|
|
39
38
|
* @param {*} [options.thisArg] - execution context
|
package/lib/validate.js
CHANGED
|
@@ -24,6 +24,7 @@ var isObject = require( '@stdlib/assert-is-plain-object' );
|
|
|
24
24
|
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
|
|
25
25
|
var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
|
|
26
26
|
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;
|
|
27
|
+
var format = require( '@stdlib/string-format' );
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
// MAIN //
|
|
@@ -53,7 +54,7 @@ var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimit
|
|
|
53
54
|
*/
|
|
54
55
|
function validate( opts, options ) {
|
|
55
56
|
if ( !isObject( options ) ) {
|
|
56
|
-
return new TypeError( 'invalid argument. Options must be an object. Value:
|
|
57
|
+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
|
|
57
58
|
}
|
|
58
59
|
if ( hasOwnProp( options, 'thisArg' ) ) {
|
|
59
60
|
opts.thisArg = options.thisArg;
|
|
@@ -61,13 +62,13 @@ function validate( opts, options ) {
|
|
|
61
62
|
if ( hasOwnProp( options, 'series' ) ) {
|
|
62
63
|
opts.series = options.series;
|
|
63
64
|
if ( !isBoolean( opts.series ) ) {
|
|
64
|
-
return new TypeError( 'invalid option. `
|
|
65
|
+
return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'series', opts.series ) );
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
if ( hasOwnProp( options, 'limit' ) ) {
|
|
68
69
|
opts.limit = options.limit;
|
|
69
70
|
if ( !isPositiveInteger( opts.limit ) ) {
|
|
70
|
-
return new TypeError( 'invalid option. `
|
|
71
|
+
return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'limit', opts.limit ) );
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/utils-async-inmap-right",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Invoke a function for each element in a collection and update the collection in-place, iterating from right to left.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,25 +37,28 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/assert-has-own-property": "^0.
|
|
41
|
-
"@stdlib/assert-is-boolean": "^0.0
|
|
42
|
-
"@stdlib/assert-is-collection": "^0.0
|
|
43
|
-
"@stdlib/assert-is-function": "^0.0
|
|
44
|
-
"@stdlib/assert-is-plain-object": "^0.0
|
|
45
|
-
"@stdlib/assert-is-positive-integer": "^0.0
|
|
46
|
-
"@stdlib/constants-float64-pinf": "^0.0
|
|
47
|
-
"@stdlib/
|
|
48
|
-
"@stdlib/
|
|
49
|
-
"
|
|
40
|
+
"@stdlib/assert-has-own-property": "^0.1.1",
|
|
41
|
+
"@stdlib/assert-is-boolean": "^0.2.0",
|
|
42
|
+
"@stdlib/assert-is-collection": "^0.2.0",
|
|
43
|
+
"@stdlib/assert-is-function": "^0.2.0",
|
|
44
|
+
"@stdlib/assert-is-plain-object": "^0.2.0",
|
|
45
|
+
"@stdlib/assert-is-positive-integer": "^0.2.0",
|
|
46
|
+
"@stdlib/constants-float64-pinf": "^0.2.0",
|
|
47
|
+
"@stdlib/string-format": "^0.2.0",
|
|
48
|
+
"@stdlib/types": "^0.3.1",
|
|
49
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0",
|
|
50
|
+
"debug": "^2.6.9",
|
|
51
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.1"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
|
-
"@stdlib/
|
|
53
|
-
"@stdlib/
|
|
54
|
-
"@stdlib/
|
|
55
|
-
"@stdlib/utils-noop": "^0.0.x",
|
|
54
|
+
"@stdlib/constants-float64-eps": "^0.1.1",
|
|
55
|
+
"@stdlib/fs-read-file": "^0.1.1",
|
|
56
|
+
"@stdlib/utils-noop": "^0.2.0",
|
|
56
57
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
57
58
|
"istanbul": "^0.4.1",
|
|
58
|
-
"tap-
|
|
59
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
60
|
+
"@stdlib/bench-harness": "^0.1.2",
|
|
61
|
+
"@stdlib/bench": "^0.3.1"
|
|
59
62
|
},
|
|
60
63
|
"engines": {
|
|
61
64
|
"node": ">=0.10.0",
|
|
@@ -94,7 +97,7 @@
|
|
|
94
97
|
"async"
|
|
95
98
|
],
|
|
96
99
|
"funding": {
|
|
97
|
-
"type": "
|
|
98
|
-
"url": "https://
|
|
100
|
+
"type": "opencollective",
|
|
101
|
+
"url": "https://opencollective.com/stdlib"
|
|
99
102
|
}
|
|
100
103
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( collection, [options,] fcn, done )
|
|
3
|
-
Invokes a function once for each element in a collection and updates a
|
|
4
|
-
collection in-place, iterating from right to left.
|
|
5
|
-
|
|
6
|
-
When invoked, `fcn` is provided a maximum of four arguments:
|
|
7
|
-
|
|
8
|
-
- `value`: collection value
|
|
9
|
-
- `index`: collection index
|
|
10
|
-
- `collection`: the input collection
|
|
11
|
-
- `next`: a callback to be invoked after processing a collection `value`
|
|
12
|
-
|
|
13
|
-
The actual number of provided arguments depends on function length. If `fcn`
|
|
14
|
-
accepts two arguments, `fcn` is provided:
|
|
15
|
-
|
|
16
|
-
- `value`
|
|
17
|
-
- `next`
|
|
18
|
-
|
|
19
|
-
If `fcn` accepts three arguments, `fcn` is provided:
|
|
20
|
-
|
|
21
|
-
- `value`
|
|
22
|
-
- `index`
|
|
23
|
-
- `next`
|
|
24
|
-
|
|
25
|
-
For every other `fcn` signature, `fcn` is provided all four arguments.
|
|
26
|
-
|
|
27
|
-
The `next` callback accepts two arguments:
|
|
28
|
-
|
|
29
|
-
- `error`: error argument
|
|
30
|
-
- `result`: value used to update the collection
|
|
31
|
-
|
|
32
|
-
If a provided function calls the `next` callback with a truthy `error`
|
|
33
|
-
argument, the function suspends execution and immediately calls the `done`
|
|
34
|
-
callback for subsequent `error` handling. Note, however, that the function
|
|
35
|
-
may have mutated an input collection during prior invocations, resulting in
|
|
36
|
-
a partially mutated collection.
|
|
37
|
-
|
|
38
|
-
Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony,
|
|
39
|
-
wrap the `done` callback in a function which either executes at the end of
|
|
40
|
-
the current stack (e.g., `nextTick`) or during a subsequent turn of the
|
|
41
|
-
event loop (e.g., `setImmediate`, `setTimeout`).
|
|
42
|
-
|
|
43
|
-
The function does not support dynamic collection resizing.
|
|
44
|
-
|
|
45
|
-
The function does not skip `undefined` elements.
|
|
46
|
-
|
|
47
|
-
Parameters
|
|
48
|
-
----------
|
|
49
|
-
collection: Array|TypedArray|Object
|
|
50
|
-
Input collection over which to iterate. If provided an object, the
|
|
51
|
-
object must be array-like (excluding strings and functions).
|
|
52
|
-
|
|
53
|
-
options: Object (optional)
|
|
54
|
-
Function options.
|
|
55
|
-
|
|
56
|
-
options.limit: integer (optional)
|
|
57
|
-
Maximum number of pending invocations. Default: Infinity.
|
|
58
|
-
|
|
59
|
-
options.series: boolean (optional)
|
|
60
|
-
Boolean indicating whether to process each collection element
|
|
61
|
-
sequentially. Default: false.
|
|
62
|
-
|
|
63
|
-
options.thisArg: any (optional)
|
|
64
|
-
Execution context.
|
|
65
|
-
|
|
66
|
-
fcn: Function
|
|
67
|
-
The function to invoke for each element in a collection.
|
|
68
|
-
|
|
69
|
-
done: Function
|
|
70
|
-
A callback invoked either upon processing all collection elements or
|
|
71
|
-
upon encountering an error.
|
|
72
|
-
|
|
73
|
-
Examples
|
|
74
|
-
--------
|
|
75
|
-
// Basic usage:
|
|
76
|
-
> function fcn( value, index, next ) {
|
|
77
|
-
... setTimeout( onTimeout, value );
|
|
78
|
-
... function onTimeout() {
|
|
79
|
-
... console.log( value );
|
|
80
|
-
... next( null, value*index );
|
|
81
|
-
... }
|
|
82
|
-
... };
|
|
83
|
-
> function done( error, collection ) {
|
|
84
|
-
... if ( error ) {
|
|
85
|
-
... throw error;
|
|
86
|
-
... }
|
|
87
|
-
... console.log( collection === arr );
|
|
88
|
-
... console.log( collection );
|
|
89
|
-
... };
|
|
90
|
-
> var arr = [ 1000, 2500, 3000 ];
|
|
91
|
-
> {{alias}}( arr, fcn, done )
|
|
92
|
-
1000
|
|
93
|
-
2500
|
|
94
|
-
3000
|
|
95
|
-
true
|
|
96
|
-
[ 0, 2500, 6000 ]
|
|
97
|
-
|
|
98
|
-
// Limit number of concurrent invocations:
|
|
99
|
-
> function fcn( value, index, next ) {
|
|
100
|
-
... setTimeout( onTimeout, value );
|
|
101
|
-
... function onTimeout() {
|
|
102
|
-
... console.log( value );
|
|
103
|
-
... next( null, value*index );
|
|
104
|
-
... }
|
|
105
|
-
... };
|
|
106
|
-
> function done( error, collection ) {
|
|
107
|
-
... if ( error ) {
|
|
108
|
-
... throw error;
|
|
109
|
-
... }
|
|
110
|
-
... console.log( collection === arr );
|
|
111
|
-
... console.log( collection );
|
|
112
|
-
... };
|
|
113
|
-
> var opts = { 'limit': 2 };
|
|
114
|
-
> var arr = [ 1000, 2500, 3000 ];
|
|
115
|
-
> {{alias}}( arr, opts, fcn, done )
|
|
116
|
-
2500
|
|
117
|
-
3000
|
|
118
|
-
1000
|
|
119
|
-
true
|
|
120
|
-
[ 0, 2500, 6000 ]
|
|
121
|
-
|
|
122
|
-
// Process sequentially:
|
|
123
|
-
> function fcn( value, index, next ) {
|
|
124
|
-
... setTimeout( onTimeout, value );
|
|
125
|
-
... function onTimeout() {
|
|
126
|
-
... console.log( value );
|
|
127
|
-
... next( null, value*index );
|
|
128
|
-
... }
|
|
129
|
-
... };
|
|
130
|
-
> function done( error, collection ) {
|
|
131
|
-
... if ( error ) {
|
|
132
|
-
... throw error;
|
|
133
|
-
... }
|
|
134
|
-
... console.log( collection === arr );
|
|
135
|
-
... console.log( collection );
|
|
136
|
-
... };
|
|
137
|
-
> var opts = { 'series': true };
|
|
138
|
-
> var arr = [ 1000, 2500, 3000 ];
|
|
139
|
-
> {{alias}}( arr, opts, fcn, done )
|
|
140
|
-
3000
|
|
141
|
-
2500
|
|
142
|
-
1000
|
|
143
|
-
true
|
|
144
|
-
[ 0, 2500, 6000 ]
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
{{alias}}.factory( [options,] fcn )
|
|
148
|
-
Returns a function which invokes a function once for each element in a
|
|
149
|
-
collection and updates a collection in-place, iterating from right to left.
|
|
150
|
-
|
|
151
|
-
Parameters
|
|
152
|
-
----------
|
|
153
|
-
options: Object (optional)
|
|
154
|
-
Function options.
|
|
155
|
-
|
|
156
|
-
options.limit: integer (optional)
|
|
157
|
-
Maximum number of pending invocations. Default: Infinity.
|
|
158
|
-
|
|
159
|
-
options.series: boolean (optional)
|
|
160
|
-
Boolean indicating whether to process each collection element
|
|
161
|
-
sequentially. Default: false.
|
|
162
|
-
|
|
163
|
-
options.thisArg: any (optional)
|
|
164
|
-
Execution context.
|
|
165
|
-
|
|
166
|
-
fcn: Function
|
|
167
|
-
The function to invoke for each element in a collection.
|
|
168
|
-
|
|
169
|
-
Returns
|
|
170
|
-
-------
|
|
171
|
-
out: Function
|
|
172
|
-
A function which invokes a function for each element in a collection.
|
|
173
|
-
|
|
174
|
-
Examples
|
|
175
|
-
--------
|
|
176
|
-
> function fcn( value, index, next ) {
|
|
177
|
-
... setTimeout( onTimeout, value );
|
|
178
|
-
... function onTimeout() {
|
|
179
|
-
... console.log( value );
|
|
180
|
-
... next( null, value*index );
|
|
181
|
-
... }
|
|
182
|
-
... };
|
|
183
|
-
> var opts = { 'series': true };
|
|
184
|
-
> var f = {{alias}}.factory( opts, fcn );
|
|
185
|
-
> function done( error, collection ) {
|
|
186
|
-
... if ( error ) {
|
|
187
|
-
... throw error;
|
|
188
|
-
... }
|
|
189
|
-
... console.log( collection === arr );
|
|
190
|
-
... console.log( collection );
|
|
191
|
-
... };
|
|
192
|
-
> var arr = [ 1000, 2500, 3000 ];
|
|
193
|
-
> f( arr, done )
|
|
194
|
-
3000
|
|
195
|
-
2500
|
|
196
|
-
1000
|
|
197
|
-
true
|
|
198
|
-
[ 0, 2500, 6000 ]
|
|
199
|
-
> arr = [ 1000, 1500, 2000 ];
|
|
200
|
-
> f( arr, done )
|
|
201
|
-
2000
|
|
202
|
-
1500
|
|
203
|
-
1000
|
|
204
|
-
true
|
|
205
|
-
[ 0, 1500, 4000 ]
|
|
206
|
-
|
|
207
|
-
See Also
|
|
208
|
-
--------
|
|
209
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2021 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
|
-
import inmapRightAsync = require( './index' );
|
|
20
|
-
|
|
21
|
-
const fcn = ( value: number, index: number, next: Function ): void => {
|
|
22
|
-
next( null, value * index );
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const done = ( error: Error | null ) => {
|
|
26
|
-
if ( error ) {
|
|
27
|
-
throw error;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// TESTS //
|
|
33
|
-
|
|
34
|
-
// The function returns void...
|
|
35
|
-
{
|
|
36
|
-
inmapRightAsync( [ 0, 1, 1 ], fcn, done ); // $ExpectType void
|
|
37
|
-
inmapRightAsync( [ -1, 1, 2 ], fcn, done ); // $ExpectType void
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// The compiler throws an error if the function is provided a first argument which is not a collection...
|
|
41
|
-
{
|
|
42
|
-
inmapRightAsync( 2, fcn, done ); // $ExpectError
|
|
43
|
-
inmapRightAsync( false, fcn, done ); // $ExpectError
|
|
44
|
-
inmapRightAsync( true, fcn, done ); // $ExpectError
|
|
45
|
-
inmapRightAsync( {}, fcn, done ); // $ExpectError
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// The compiler throws an error if the function is provided a second argument which is not a function...
|
|
49
|
-
{
|
|
50
|
-
inmapRightAsync( [ 1, 2, 3 ], 2, done ); // $ExpectError
|
|
51
|
-
inmapRightAsync( [ 1, 2, 3 ], false, done ); // $ExpectError
|
|
52
|
-
inmapRightAsync( [ 1, 2, 3 ], true, done ); // $ExpectError
|
|
53
|
-
inmapRightAsync( [ 1, 2, 3 ], 'abc', done ); // $ExpectError
|
|
54
|
-
inmapRightAsync( [ 1, 2, 3 ], {}, done ); // $ExpectError
|
|
55
|
-
inmapRightAsync( [ 1, 2, 3 ], [], done ); // $ExpectError
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// The compiler throws an error if the function is provided a last argument which is not a function having a supported signature...
|
|
59
|
-
{
|
|
60
|
-
inmapRightAsync( [ 1, 2, 3 ], fcn, 2 ); // $ExpectError
|
|
61
|
-
inmapRightAsync( [ 1, 2, 3 ], fcn, false ); // $ExpectError
|
|
62
|
-
inmapRightAsync( [ 1, 2, 3 ], fcn, true ); // $ExpectError
|
|
63
|
-
inmapRightAsync( [ 1, 2, 3 ], fcn, 'abc' ); // $ExpectError
|
|
64
|
-
inmapRightAsync( [ 1, 2, 3 ], fcn, {} ); // $ExpectError
|
|
65
|
-
inmapRightAsync( [ 1, 2, 3 ], fcn, [] ); // $ExpectError
|
|
66
|
-
inmapRightAsync( [ 1, 2, 3 ], fcn, ( x: number ): number => x ); // $ExpectError
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// The compiler throws an error if the function is provided an invalid number of arguments...
|
|
70
|
-
{
|
|
71
|
-
inmapRightAsync(); // $ExpectError
|
|
72
|
-
inmapRightAsync( [ 1, 2, 3 ] ); // $ExpectError
|
|
73
|
-
inmapRightAsync( [ 1, 2, 3 ], fcn ); // $ExpectError
|
|
74
|
-
inmapRightAsync( [ 1, 2, 3 ], {}, fcn, done, {} ); // $ExpectError
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Attached to main export is a `factory` method which returns a function...
|
|
78
|
-
{
|
|
79
|
-
inmapRightAsync.factory( fcn ); // $ExpectType FactoryFunction
|
|
80
|
-
inmapRightAsync.factory( { 'series': true }, fcn ); // $ExpectType FactoryFunction
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// The compiler throws an error if the `factory` method is provided an options argument which is not an object...
|
|
84
|
-
{
|
|
85
|
-
inmapRightAsync.factory( [], fcn ); // $ExpectError
|
|
86
|
-
inmapRightAsync.factory( 123, fcn ); // $ExpectError
|
|
87
|
-
inmapRightAsync.factory( 'abc', fcn ); // $ExpectError
|
|
88
|
-
inmapRightAsync.factory( false, fcn ); // $ExpectError
|
|
89
|
-
inmapRightAsync.factory( true, fcn ); // $ExpectError
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// The compiler throws an error if the `factory` method is provided a last argument which is not a function...
|
|
93
|
-
{
|
|
94
|
-
inmapRightAsync.factory( {} ); // $ExpectError
|
|
95
|
-
inmapRightAsync.factory( true ); // $ExpectError
|
|
96
|
-
inmapRightAsync.factory( false ); // $ExpectError
|
|
97
|
-
inmapRightAsync.factory( {}, 123 ); // $ExpectError
|
|
98
|
-
inmapRightAsync.factory( {}, 'abc' ); // $ExpectError
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// The compiler throws an error if the function returned by the `factory` method is provided invalid arguments...
|
|
102
|
-
{
|
|
103
|
-
const fcn1 = inmapRightAsync.factory( fcn );
|
|
104
|
-
fcn1( 12, done ); // $ExpectError
|
|
105
|
-
fcn1( true, done ); // $ExpectError
|
|
106
|
-
fcn1( false, done ); // $ExpectError
|
|
107
|
-
fcn1( {}, done ); // $ExpectError
|
|
108
|
-
|
|
109
|
-
fcn1( [ 1, 2, 3 ], 12 ); // $ExpectError
|
|
110
|
-
fcn1( [ 1, 2, 3 ], true ); // $ExpectError
|
|
111
|
-
fcn1( [ 1, 2, 3 ], false ); // $ExpectError
|
|
112
|
-
fcn1( [ 1, 2, 3 ], '5' ); // $ExpectError
|
|
113
|
-
fcn1( [ 1, 2, 3 ], {} ); // $ExpectError
|
|
114
|
-
fcn1( [ 1, 2, 3 ], [] ); // $ExpectError
|
|
115
|
-
fcn1( [ 1, 2, 3 ], ( x: number ): number => x ); // $ExpectError
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// The compiler throws an error if the function returned by the `factory` method is provided an unsupported number of arguments...
|
|
119
|
-
{
|
|
120
|
-
const fcn1 = inmapRightAsync.factory( fcn );
|
|
121
|
-
fcn1(); // $ExpectError
|
|
122
|
-
fcn1( [ 1, 2, 3 ] ); // $ExpectError
|
|
123
|
-
fcn1( [ 1, 2, 3 ], done, {} ); // $ExpectError
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// The compiler throws an error if the `factory` method is provided a `limit` option which is not a number...
|
|
127
|
-
{
|
|
128
|
-
inmapRightAsync.factory( { 'limit': '12' }, fcn ); // $ExpectError
|
|
129
|
-
inmapRightAsync.factory( { 'limit': true }, fcn ); // $ExpectError
|
|
130
|
-
inmapRightAsync.factory( { 'limit': false }, fcn ); // $ExpectError
|
|
131
|
-
inmapRightAsync.factory( { 'limit': {} }, fcn ); // $ExpectError
|
|
132
|
-
inmapRightAsync.factory( { 'limit': [] }, fcn ); // $ExpectError
|
|
133
|
-
inmapRightAsync.factory( { 'limit': ( x: number ): number => x }, fcn ); // $ExpectError
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// The compiler throws an error if the `factory` method is provided a `series` option which is not a boolean...
|
|
137
|
-
{
|
|
138
|
-
inmapRightAsync.factory( { 'series': '12' }, fcn ); // $ExpectError
|
|
139
|
-
inmapRightAsync.factory( { 'series': 12 }, fcn ); // $ExpectError
|
|
140
|
-
inmapRightAsync.factory( { 'series': {} }, fcn ); // $ExpectError
|
|
141
|
-
inmapRightAsync.factory( { 'series': [] }, fcn ); // $ExpectError
|
|
142
|
-
inmapRightAsync.factory( { 'series': ( x: number ): number => x }, fcn ); // $ExpectError
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// The compiler throws an error if the `factory` method is provided an invalid number of arguments...
|
|
146
|
-
{
|
|
147
|
-
inmapRightAsync.factory(); // $ExpectError
|
|
148
|
-
inmapRightAsync.factory( {}, fcn, {} ); // $ExpectError
|
|
149
|
-
}
|