@stdlib/utils-async-for-each-right 0.0.8 → 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/CITATION.cff ADDED
@@ -0,0 +1,30 @@
1
+ cff-version: 1.2.0
2
+ title: stdlib
3
+ message: >-
4
+ If you use this software, please cite it using the
5
+ metadata from this file.
6
+
7
+ type: software
8
+
9
+ authors:
10
+ - name: The Stdlib Authors
11
+ url: https://github.com/stdlib-js/stdlib/graphs/contributors
12
+
13
+ repository-code: https://github.com/stdlib-js/stdlib
14
+ url: https://stdlib.io
15
+
16
+ abstract: |
17
+ Standard library for JavaScript and Node.js.
18
+
19
+ keywords:
20
+ - JavaScript
21
+ - Node.js
22
+ - TypeScript
23
+ - standard library
24
+ - scientific computing
25
+ - numerical computing
26
+ - statistical computing
27
+
28
+ license: Apache-2.0 AND BSL-1.0
29
+
30
+ date-released: 2016
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-2022 The Stdlib Authors.
1
+ Copyright (c) 2016-2023 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
  # forEachRightAsync
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] -->
@@ -83,9 +94,9 @@ forEachRightAsync( arr, onDuration, done );
83
94
 
84
95
  The function accepts the following `options`:
85
96
 
86
- - `limit`: the maximum number of pending invocations at any one time. Default: `infinity`.
87
- - `series`: `boolean` indicating whether to sequentially invoke `fcn` for each `collection` element. If `true`, the function sets `options.limit=1`. Default: `false`.
88
- - `thisArg`: the execution context for `fcn`.
97
+ - **limit**: the maximum number of pending invocations at any one time. Default: `infinity`.
98
+ - **series**: boolean indicating whether to sequentially invoke `fcn` for each `collection` element. If `true`, the function sets `options.limit=1`. Default: `false`.
99
+ - **thisArg**: the execution context for `fcn`.
89
100
 
90
101
  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`.
91
102
 
@@ -183,10 +194,10 @@ function done( error ) {
183
194
 
184
195
  When invoked, `fcn` is provided a maximum of four arguments:
185
196
 
186
- - `value`: collection value.
187
- - `index`: collection index.
188
- - `collection`: the input `collection`.
189
- - `next`: a callback which should be called once `fcn` has finished processing a collection `value`.
197
+ - **value**: collection value.
198
+ - **index**: collection index.
199
+ - **collection**: the input `collection`.
200
+ - **next**: a callback which should be called once `fcn` has finished processing a collection `value`.
190
201
 
191
202
  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.
192
203
 
@@ -345,8 +356,8 @@ forEachRightAsync( files, read, done );
345
356
 
346
357
  ## See Also
347
358
 
348
- - <span class="package-name">[`@stdlib/utils/async/for-each`][@stdlib/utils/async/for-each]</span><span class="delimiter">: </span><span class="description">invoke a function once for each element in a collection.</span>
349
- - <span class="package-name">[`@stdlib/utils/for-each-right`][@stdlib/utils/for-each-right]</span><span class="delimiter">: </span><span class="description">invoke a function for each element in a collection, iterating from right to left.</span>
359
+ - <span class="package-name">[`@stdlib/utils-async/for-each`][@stdlib/utils/async/for-each]</span><span class="delimiter">: </span><span class="description">invoke a function once for each element in a collection.</span>
360
+ - <span class="package-name">[`@stdlib/utils-for-each-right`][@stdlib/utils/for-each-right]</span><span class="delimiter">: </span><span class="description">invoke a function for each element in a collection, iterating from right to left.</span>
350
361
 
351
362
  </section>
352
363
 
@@ -378,7 +389,7 @@ See [LICENSE][stdlib-license].
378
389
 
379
390
  ## Copyright
380
391
 
381
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
392
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
382
393
 
383
394
  </section>
384
395
 
@@ -391,8 +402,8 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
391
402
  [npm-image]: http://img.shields.io/npm/v/@stdlib/utils-async-for-each-right.svg
392
403
  [npm-url]: https://npmjs.org/package/@stdlib/utils-async-for-each-right
393
404
 
394
- [test-image]: https://github.com/stdlib-js/utils-async-for-each-right/actions/workflows/test.yml/badge.svg
395
- [test-url]: https://github.com/stdlib-js/utils-async-for-each-right/actions/workflows/test.yml
405
+ [test-image]: https://github.com/stdlib-js/utils-async-for-each-right/actions/workflows/test.yml/badge.svg?branch=v0.1.0
406
+ [test-url]: https://github.com/stdlib-js/utils-async-for-each-right/actions/workflows/test.yml?query=branch:v0.1.0
396
407
 
397
408
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-async-for-each-right/main.svg
398
409
  [coverage-url]: https://codecov.io/github/stdlib-js/utils-async-for-each-right?branch=main
@@ -404,19 +415,20 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
404
415
 
405
416
  -->
406
417
 
418
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
419
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
420
+
421
+ [stdlib]: https://github.com/stdlib-js/stdlib
422
+
423
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
424
+
407
425
  [umd]: https://github.com/umdjs/umd
408
426
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
409
427
 
410
428
  [deno-url]: https://github.com/stdlib-js/utils-async-for-each-right/tree/deno
411
429
  [umd-url]: https://github.com/stdlib-js/utils-async-for-each-right/tree/umd
412
430
  [esm-url]: https://github.com/stdlib-js/utils-async-for-each-right/tree/esm
413
-
414
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
415
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
416
-
417
- [stdlib]: https://github.com/stdlib-js/stdlib
418
-
419
- [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
431
+ [branches-url]: https://github.com/stdlib-js/utils-async-for-each-right/blob/main/branches.md
420
432
 
421
433
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/utils-async-for-each-right/main/LICENSE
422
434
 
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import forEachRightAsync from '../docs/types/index';
3
+ export = forEachRightAsync;
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";var v=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var w=v(function(K,b){
2
+ var C=require('@stdlib/assert-is-plain-object/dist'),o=require('@stdlib/assert-has-own-property/dist'),V=require('@stdlib/assert-is-boolean/dist').isPrimitive,N=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,h=require('@stdlib/error-tools-fmtprodmsg/dist');function R(e,r){return C(r)?(o(r,"thisArg")&&(e.thisArg=r.thisArg),o(r,"series")&&(e.series=r.series,!V(e.series))?new TypeError(h('1R72o',"series",e.series)):o(r,"limit")&&(e.limit=r.limit,!N(e.limit))?new TypeError(h('1R73P',"limit",e.limit)):null):new TypeError(h('1R72V',r));}b.exports=R
3
+ });var A=v(function(M,E){
4
+ var j=require("debug"),l=j("for-each-right-async:limit");function k(e,r,i,u){var n,m,s,t,a,f;if(t=e.length,l("Collection length: %d",t),t===0)return l("Finished processing a collection."),u();for(t<r.limit?s=t:s=r.limit,l("Concurrency limit: %d",s),l("Number of arguments: %d",i.length),n=0,a=t,f=0;f<s;f++)a>0&&y();function y(){a-=1,l("Collection element %d: %s.",a,JSON.stringify(e[a])),i.length===2?i.call(r.thisArg,e[a],g):i.length===3?i.call(r.thisArg,e[a],a,g):i.call(r.thisArg,e[a],a,e,g)}function g(c){if(!m){if(c)return m=!0,l("Encountered an error: %s",c.message),u(c);if(n+=1,l("Processed %d of %d collection elements.",n,t),a>0)return y();if(n===t)return l("Finished processing a collection."),u()}}}E.exports=k
5
+ });var q=v(function(Q,O){
6
+ var x=require('@stdlib/assert-is-function/dist'),I=require('@stdlib/assert-is-collection/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist'),L=require('@stdlib/constants-float64-pinf/dist'),B=w(),J=A();function S(e,r){var i,u,n;if(i={},arguments.length>1){if(u=B(i,e),u)throw u;n=r}else n=e;if(!x(n))throw new TypeError(d('1R73q',n));return i.series?i.limit=1:i.limit||(i.limit=L),m;function m(s,t){if(!I(s))throw new TypeError(d('1R7Ah',s));if(!x(t))throw new TypeError(d('1R73q',t));return J(s,i,n,a);function a(f){if(f)return t(f);t()}}}O.exports=S
7
+ });var F=v(function(U,T){
8
+ var P=q();function z(e,r,i,u){if(arguments.length<4)return P(r)(e,i);P(r,i)(e,u)}T.exports=z
9
+ });var D=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),p=F(),G=q();D(p,"factory",G);module.exports=p;
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( 'for-each-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.\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\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\tidx -= 1;\n\t\tdebug( 'Collection element %d: %s.', idx, JSON.stringify( collection[ idx ] ) );\n\t\tif ( fcn.length === 2 ) {\n\t\t\tfcn.call( opts.thisArg, collection[ idx ], clbk );\n\t\t} else if ( fcn.length === 3 ) {\n\t\t\tfcn.call( opts.thisArg, collection[ idx ], idx, clbk );\n\t\t} else {\n\t\t\tfcn.call( opts.thisArg, collection[ idx ], idx, collection, clbk );\n\t\t}\n\t}\n\n\t/**\n\t* Callback invoked once a provided function finishes processing a 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 ( flg ) {\n\t\t\t// Prevent further processing of collection elements:\n\t\t\treturn;\n\t\t}\n\t\tif ( error ) {\n\t\t\tflg = true;\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, 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.\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 ) {\n* if ( error ) {\n* return next( error );\n* }\n* console.log( 'Successfully read file: %s', file );\n* next();\n* }\n* }\n*\n* var opts = {\n* 'series': true\n* };\n*\n* // Create a `forEachRightAsync` function which invokes `read` for each collection element sequentially:\n* var forEachRightAsync = 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 ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Successfully read all files.' );\n* }\n*\n* // Run `read` for each element in `files`:\n* forEachRightAsync( 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 forEachRightAsync;\n\n\t/**\n\t* Invokes a function for each element in a collection, 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 forEachRightAsync( 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 );\n\t\t\t}\n\t\t\tdone();\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, 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.\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 ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Successfully read all files.' );\n* }\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* return next( error );\n* }\n* console.log( 'Successfully read file: %s', file );\n* next();\n* }\n* }\n*\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* forEachRightAsync( files, read, done );\n*/\nfunction forEachRightAsync( 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 = forEachRightAsync;\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, iterating from right to left.\n*\n* @module @stdlib/utils-async-for-each-right\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n* var forEachRightAsync = require( '@stdlib/utils-async-for-each-right' );\n*\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Successfully read all files.' );\n* }\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* error = new Error( 'unable to read file: '+file );\n* return next( error );\n* }\n* console.log( 'Successfully read file: %s', file );\n* next();\n* }\n* }\n*\n* forEachRightAsync( 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,4BAA6B,EAiBjD,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,EASP,SAASA,GAAO,CACfF,GAAO,EACPV,EAAO,6BAA8BU,EAAK,KAAK,UAAWR,EAAYQ,CAAI,CAAE,CAAE,EACzEN,EAAI,SAAW,EACnBA,EAAI,KAAMD,EAAK,QAASD,EAAYQ,CAAI,EAAGG,CAAK,EACrCT,EAAI,SAAW,EAC1BA,EAAI,KAAMD,EAAK,QAASD,EAAYQ,CAAI,EAAGA,EAAKG,CAAK,EAErDT,EAAI,KAAMD,EAAK,QAASD,EAAYQ,CAAI,EAAGA,EAAKR,EAAYW,CAAK,CAEnE,CASA,SAASA,EAAMC,EAAQ,CACtB,GAAK,CAAAP,EAIL,IAAKO,EACJ,OAAAP,EAAM,GACNP,EAAO,2BAA4Bc,EAAM,OAAQ,EAC1CT,EAAMS,CAAM,EAIpB,GAFAR,GAAS,EACTN,EAAO,0CAA2CM,EAAOG,CAAI,EACxDC,EAAM,EACV,OAAOE,EAAK,EAEb,GAAKN,IAAUG,EACd,OAAAT,EAAO,mCAAoC,EACpCK,EAAK,EAEd,CACD,CAKAP,EAAO,QAAUG,IC7HjB,IAAAc,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,IAiEZ,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,EAAmBC,EAAYC,EAAO,CAC9C,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,CAAM,EAEpBF,EAAK,CACN,CACD,CACD,CAKAf,EAAO,QAAUO,IC3JjB,IAAAW,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,IA2Dd,SAASC,EAAmBC,EAAYC,EAASC,EAAKC,EAAO,CAC5D,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", "clbk", "error", "require_factory", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "format", "PINF", "validate", "limit", "factory", "options", "fcn", "opts", "err", "f", "forEachRightAsync", "collection", "done", "clbk", "error", "require_main", "__commonJSMin", "exports", "module", "factory", "forEachRightAsync", "collection", "options", "fcn", "done", "setReadOnly", "main", "factory"]
7
+ }
@@ -16,50 +16,57 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /// <reference types="@stdlib/types"/>
22
22
 
23
- import { Collection } from '@stdlib/types/object';
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, V> {
29
29
  /**
30
- * The maximum number of pending invocations at any one time.
30
+ * Execution context.
31
31
  */
32
- limit?: number;
32
+ thisArg?: ThisParameterType<Fcn<T, V>>;
33
33
 
34
34
  /**
35
- * Boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection (default: false).
35
+ * The maximum number of pending invocations at any one time.
36
36
  */
37
- series?: boolean;
37
+ limit?: number;
38
38
 
39
39
  /**
40
- * Execution context.
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
- thisArg?: any;
42
+ series?: boolean;
43
43
  }
44
44
 
45
45
  /**
46
46
  * Callback function.
47
47
  */
48
- type NullaryCallback = () => void;
48
+ type Nullary = () => void;
49
49
 
50
50
  /**
51
51
  * Callback function.
52
52
  *
53
53
  * @param error - encountered error
54
54
  */
55
- type UnaryCallback = ( error: Error ) => void;
55
+ type Unary = ( error: Error ) => void;
56
56
 
57
57
  /**
58
58
  * Callback function.
59
59
  *
60
60
  * @param error - encountered error
61
61
  */
62
- type Callback = NullaryCallback | UnaryCallback;
62
+ type Callback = Nullary | Unary;
63
+
64
+ /**
65
+ * Callback function to invoke once the provided function has finished processing a collection value.
66
+ *
67
+ * @param error - encountered error
68
+ */
69
+ type Next = Nullary | Unary;
63
70
 
64
71
  /**
65
72
  * Function invoked for each element in a collection.
@@ -67,7 +74,7 @@ type Callback = NullaryCallback | UnaryCallback;
67
74
  * @param value - collection value
68
75
  * @param next - a callback to be invoked after processing a collection `value`
69
76
  */
70
- type Binary = ( value: any, next: Callback ) => void;
77
+ type BinaryFcn<T, V> = ( this: V, value: T, next: Next ) => void;
71
78
 
72
79
  /**
73
80
  * Function invoked for each element in a collection.
@@ -76,7 +83,7 @@ type Binary = ( value: any, next: Callback ) => void;
76
83
  * @param index - collection index
77
84
  * @param next - a callback to be invoked after processing a collection `value`
78
85
  */
79
- type Ternary = ( value: any, index: number, next: Callback ) => void;
86
+ type TernaryFcn<T, V> = ( this: V, value: T, index: number, next: Next ) => void;
80
87
 
81
88
  /**
82
89
  * Function invoked for each element in a collection.
@@ -86,7 +93,7 @@ type Ternary = ( value: any, index: number, next: Callback ) => void;
86
93
  * @param collection - input collection
87
94
  * @param next - a callback to be invoked after processing a collection `value`
88
95
  */
89
- type Quaternary = ( value: any, index: number, collection: Collection, next: Callback ) => void; // tslint-disable-line max-line-length
96
+ type QuaternaryFcn<T, V> = ( this: V, value: T, index: number, collection: Collection<T>, next: Next ) => void;
90
97
 
91
98
  /**
92
99
  * Function invoked for each element in a collection.
@@ -96,7 +103,7 @@ type Quaternary = ( value: any, index: number, collection: Collection, next: Cal
96
103
  * @param collection - input collection
97
104
  * @param next - a callback to be invoked after processing a collection `value`
98
105
  */
99
- type Fcn = Binary | Ternary | Quaternary;
106
+ type Fcn<T, V> = BinaryFcn<T, V> | TernaryFcn<T, V> | QuaternaryFcn<T, V>;
100
107
 
101
108
  /**
102
109
  * Function which invokes the provided function once for each element in a collection.
@@ -118,7 +125,6 @@ interface ForEachRightAsync {
118
125
  * - 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.
119
126
  * - 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`).
120
127
  *
121
- *
122
128
  * @param collection - input collection
123
129
  * @param options - function options
124
130
  * @param options.thisArg - execution context
@@ -160,7 +166,7 @@ interface ForEachRightAsync {
160
166
  *
161
167
  * forEachRightAsync( files, read, done );
162
168
  */
163
- ( collection: Collection, options: Options, fcn: Fcn, done: Callback ): void; // tslint-disable-line max-line-length
169
+ <T = unknown, V = unknown>( collection: Collection<T>, options: Options<T, V>, fcn: Fcn<T, V>, done: Callback ): void;
164
170
 
165
171
  /**
166
172
  * Invokes a function once for each element in a collection.
@@ -170,7 +176,6 @@ interface ForEachRightAsync {
170
176
  * - 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.
171
177
  * - 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`).
172
178
  *
173
- *
174
179
  * @param collection - input collection
175
180
  * @param options - function options
176
181
  * @param options.thisArg - execution context
@@ -212,7 +217,7 @@ interface ForEachRightAsync {
212
217
  *
213
218
  * forEachRightAsync( files, read, done );
214
219
  */
215
- ( collection: Collection, fcn: Fcn, done: Callback ): void;
220
+ <T = unknown, V = unknown>( collection: Collection<T>, fcn: Fcn<T, V>, done: Callback ): void; // tslint:disable-line:no-unnecessary-generics
216
221
 
217
222
  /**
218
223
  * Returns a function to invoke a function once for each element in a collection.
@@ -222,7 +227,6 @@ interface ForEachRightAsync {
222
227
  * - 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.
223
228
  * - 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`).
224
229
  *
225
- *
226
230
  * @param options - function options
227
231
  * @param options.thisArg - execution context
228
232
  * @param options.limit - maximum number of pending invocations at any one time
@@ -273,7 +277,7 @@ interface ForEachRightAsync {
273
277
  * // Run `read` for each element in `files`:
274
278
  * forEachRightAsync( files, done );
275
279
  */
276
- factory( options: Options, fcn: Fcn ): FactoryFunction;
280
+ factory<T = unknown, V = unknown>( options: Options<T, V>, fcn: Fcn<T, V> ): FactoryFunction;
277
281
 
278
282
  /**
279
283
  * Returns a function to invoke a function once for each element in a collection.
@@ -324,7 +328,7 @@ interface ForEachRightAsync {
324
328
  * // Run `read` for each element in `files`:
325
329
  * forEachRightAsync( files, done );
326
330
  */
327
- factory( fcn: Fcn ): FactoryFunction;
331
+ factory<T = unknown, V = unknown>( fcn: Fcn<T, V> ): FactoryFunction; // tslint:disable-line:no-unnecessary-generics
328
332
  }
329
333
 
330
334
  /**
@@ -335,7 +339,6 @@ interface ForEachRightAsync {
335
339
  * - 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.
336
340
  * - 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`).
337
341
  *
338
- *
339
342
  * @param collection - input collection
340
343
  * @param options - function options
341
344
  * @param options.thisArg - execution context
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.
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
@@ -106,7 +106,7 @@ function factory( options, fcn ) {
106
106
  f = options;
107
107
  }
108
108
  if ( !isFunction( f ) ) {
109
- throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+f+'`.' );
109
+ throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );
110
110
  }
111
111
  if ( opts.series ) {
112
112
  opts.limit = 1;
@@ -127,10 +127,10 @@ function factory( options, fcn ) {
127
127
  */
128
128
  function forEachRightAsync( collection, done ) {
129
129
  if ( !isCollection( collection ) ) {
130
- throw new TypeError( 'invalid argument. First argument must be a collection. Value: `'+collection+'.`' );
130
+ throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );
131
131
  }
132
132
  if ( !isFunction( done ) ) {
133
- throw new TypeError( 'invalid argument. Last argument must be a function. Value: `'+done+'`.' );
133
+ throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );
134
134
  }
135
135
  return limit( collection, opts, f, clbk );
136
136
 
package/lib/index.js CHANGED
@@ -61,15 +61,15 @@
61
61
  // MODULES //
62
62
 
63
63
  var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
64
- var forEachRightAsync = require( './for_each_right.js' );
64
+ var main = require( './main.js' );
65
65
  var factory = require( './factory.js' );
66
66
 
67
67
 
68
68
  // MAIN //
69
69
 
70
- setReadOnly( forEachRightAsync, 'factory', factory );
70
+ setReadOnly( main, 'factory', factory );
71
71
 
72
72
 
73
73
  // EXPORTS //
74
74
 
75
- module.exports = forEachRightAsync;
75
+ 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.
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: `' + options + '`.' );
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. `series` option must be a boolean primitive. Option: `' + opts.series + '`.' );
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. `limit` option must be a positive integer. Option: `' + opts.limit + '`.' );
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-for-each-right",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "description": "Invoke a function once for each element in a collection, iterating from right to left.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,24 +37,26 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/assert-has-own-property": "^0.0.x",
41
- "@stdlib/assert-is-boolean": "^0.0.x",
42
- "@stdlib/assert-is-collection": "^0.0.x",
43
- "@stdlib/assert-is-function": "^0.0.x",
44
- "@stdlib/assert-is-plain-object": "^0.0.x",
45
- "@stdlib/assert-is-positive-integer": "^0.0.x",
46
- "@stdlib/constants-float64-pinf": "^0.0.x",
47
- "@stdlib/types": "^0.0.x",
48
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x",
49
- "debug": "^2.6.9"
40
+ "@stdlib/assert-has-own-property": "^0.1.0",
41
+ "@stdlib/assert-is-boolean": "^0.1.0",
42
+ "@stdlib/assert-is-collection": "^0.1.0",
43
+ "@stdlib/assert-is-function": "^0.1.0",
44
+ "@stdlib/assert-is-plain-object": "^0.1.0",
45
+ "@stdlib/assert-is-positive-integer": "^0.1.0",
46
+ "@stdlib/constants-float64-pinf": "^0.1.0",
47
+ "@stdlib/string-format": "^0.1.0",
48
+ "@stdlib/types": "^0.1.0",
49
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0",
50
+ "debug": "^2.6.9",
51
+ "@stdlib/error-tools-fmtprodmsg": "^0.1.0"
50
52
  },
51
53
  "devDependencies": {
52
- "@stdlib/bench": "^0.0.x",
53
- "@stdlib/fs-read-file": "^0.0.x",
54
- "@stdlib/utils-noop": "^0.0.x",
54
+ "@stdlib/bench": "^0.1.0",
55
+ "@stdlib/fs-read-file": "^0.1.0",
56
+ "@stdlib/utils-noop": "^0.1.0",
55
57
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
56
58
  "istanbul": "^0.4.1",
57
- "tap-spec": "5.x.x"
59
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
58
60
  },
59
61
  "engines": {
60
62
  "node": ">=0.10.0",
@@ -94,7 +96,7 @@
94
96
  "array"
95
97
  ],
96
98
  "funding": {
97
- "type": "patreon",
98
- "url": "https://www.patreon.com/athan"
99
+ "type": "opencollective",
100
+ "url": "https://opencollective.com/stdlib"
99
101
  }
100
102
  }
package/docs/repl.txt DELETED
@@ -1,193 +0,0 @@
1
-
2
- {{alias}}( collection, [options,] fcn, done )
3
- Invokes a function once for each element in a collection, iterating from
4
- 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
- If a provided function calls the `next` callback with a truthy `error`
28
- argument, the function suspends execution and immediately calls the `done`
29
- callback for subsequent `error` handling.
30
-
31
- Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony,
32
- wrap the `done` callback in a function which either executes at the end of
33
- the current stack (e.g., `nextTick`) or during a subsequent turn of the
34
- event loop (e.g., `setImmediate`, `setTimeout`).
35
-
36
- The function does not support dynamic collection resizing.
37
-
38
- The function does not skip `undefined` elements.
39
-
40
- Parameters
41
- ----------
42
- collection: Array|TypedArray|Object
43
- Input collection over which to iterate. If provided an object, the
44
- object must be array-like (excluding strings and functions).
45
-
46
- options: Object (optional)
47
- Function options.
48
-
49
- options.limit: integer (optional)
50
- Maximum number of pending invocations. Default: Infinity.
51
-
52
- options.series: boolean (optional)
53
- Boolean indicating whether to process each collection element
54
- sequentially. Default: false.
55
-
56
- options.thisArg: any (optional)
57
- Execution context.
58
-
59
- fcn: Function
60
- The function to invoke for each element in a collection.
61
-
62
- done: Function
63
- A callback invoked either upon processing all collection elements or
64
- upon encountering an error.
65
-
66
- Examples
67
- --------
68
- // Basic usage:
69
- > function onDuration( value, next ) {
70
- ... setTimeout( onTimeout, value );
71
- ... function onTimeout() {
72
- ... console.log( value );
73
- ... next();
74
- ... }
75
- ... };
76
- > function done( error ) {
77
- ... if ( error ) {
78
- ... throw error;
79
- ... }
80
- ... console.log( 'Done.' );
81
- ... };
82
- > var arr = [ 1000, 2500, 3000 ];
83
- > {{alias}}( arr, onDuration, done )
84
- 1000
85
- 2500
86
- 3000
87
- Done.
88
-
89
- // Limit number of concurrent invocations:
90
- > function onDuration( value, next ) {
91
- ... setTimeout( onTimeout, value );
92
- ... function onTimeout() {
93
- ... console.log( value );
94
- ... next();
95
- ... }
96
- ... };
97
- > function done( error ) {
98
- ... if ( error ) {
99
- ... throw error;
100
- ... }
101
- ... console.log( 'Done.' );
102
- ... };
103
- > var opts = { 'limit': 2 };
104
- > var arr = [ 1000, 2500, 3000 ];
105
- > {{alias}}( arr, opts, onDuration, done )
106
- 2500
107
- 3000
108
- 1000
109
- Done.
110
-
111
- // Process sequentially:
112
- > function onDuration( value, next ) {
113
- ... setTimeout( onTimeout, value );
114
- ... function onTimeout() {
115
- ... console.log( value );
116
- ... next();
117
- ... }
118
- ... };
119
- > function done( error ) {
120
- ... if ( error ) {
121
- ... throw error;
122
- ... }
123
- ... console.log( 'Done.' );
124
- ... };
125
- > var opts = { 'series': true };
126
- > var arr = [ 1000, 2500, 3000 ];
127
- > {{alias}}( arr, opts, onDuration, done )
128
- 3000
129
- 2500
130
- 1000
131
- Done.
132
-
133
-
134
- {{alias}}.factory( [options,] fcn )
135
- Returns a function which invokes a function once for each element in a
136
- collection, iterating from right to left.
137
-
138
- Parameters
139
- ----------
140
- options: Object (optional)
141
- Function options.
142
-
143
- options.limit: integer (optional)
144
- Maximum number of pending invocations. Default: Infinity.
145
-
146
- options.series: boolean (optional)
147
- Boolean indicating whether to process each collection element
148
- sequentially. Default: false.
149
-
150
- options.thisArg: any (optional)
151
- Execution context.
152
-
153
- fcn: Function
154
- The function to invoke for each element in a collection.
155
-
156
- Returns
157
- -------
158
- out: Function
159
- A function which invokes a function for each element in a collection.
160
-
161
- Examples
162
- --------
163
- > function onDuration( value, next ) {
164
- ... setTimeout( onTimeout, value );
165
- ... function onTimeout() {
166
- ... console.log( value );
167
- ... next();
168
- ... }
169
- ... };
170
- > var opts = { 'series': true };
171
- > var f = {{alias}}.factory( opts, onDuration );
172
- > function done( error ) {
173
- ... if ( error ) {
174
- ... throw error;
175
- ... }
176
- ... console.log( 'Done.' );
177
- ... };
178
- > var arr = [ 1000, 2500, 3000 ];
179
- > f( arr, done )
180
- 3000
181
- 2500
182
- 1000
183
- Done.
184
- > arr = [ 1000, 1500, 2000 ];
185
- > f( arr, done )
186
- 2000
187
- 1500
188
- 1000
189
- Done.
190
-
191
- See Also
192
- --------
193
-
@@ -1,154 +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 forEachRightAsync = require( './index' );
20
-
21
- let counter = 0;
22
- const add = ( v: number, next: Function ): void => {
23
- counter += v;
24
- next();
25
- };
26
-
27
- const done = ( error: Error | null ) => {
28
- if ( error ) {
29
- throw error;
30
- }
31
- if ( counter <= 0 ) {
32
- throw new Error( '`counter` is not a positive number' );
33
- }
34
- };
35
-
36
-
37
- // TESTS //
38
-
39
- // The function returns void...
40
- {
41
- forEachRightAsync( [ 0, 1, 1 ], add, done ); // $ExpectType void
42
- forEachRightAsync( [ -1, 1, 2 ], add, done ); // $ExpectType void
43
- }
44
-
45
- // The compiler throws an error if the function is provided a first argument which is not a collection...
46
- {
47
- forEachRightAsync( 2, add, done ); // $ExpectError
48
- forEachRightAsync( false, add, done ); // $ExpectError
49
- forEachRightAsync( true, add, done ); // $ExpectError
50
- forEachRightAsync( {}, add, done ); // $ExpectError
51
- }
52
-
53
- // The compiler throws an error if the function is provided a second argument which is not a function...
54
- {
55
- forEachRightAsync( [ 1, 2, 3 ], 2, done ); // $ExpectError
56
- forEachRightAsync( [ 1, 2, 3 ], false, done ); // $ExpectError
57
- forEachRightAsync( [ 1, 2, 3 ], true, done ); // $ExpectError
58
- forEachRightAsync( [ 1, 2, 3 ], 'abc', done ); // $ExpectError
59
- forEachRightAsync( [ 1, 2, 3 ], {}, done ); // $ExpectError
60
- forEachRightAsync( [ 1, 2, 3 ], [], done ); // $ExpectError
61
- }
62
-
63
- // The compiler throws an error if the function is provided a last argument which is not a function having a supported signature...
64
- {
65
- forEachRightAsync( [ 1, 2, 3 ], add, 2 ); // $ExpectError
66
- forEachRightAsync( [ 1, 2, 3 ], add, false ); // $ExpectError
67
- forEachRightAsync( [ 1, 2, 3 ], add, true ); // $ExpectError
68
- forEachRightAsync( [ 1, 2, 3 ], add, 'abc' ); // $ExpectError
69
- forEachRightAsync( [ 1, 2, 3 ], add, {} ); // $ExpectError
70
- forEachRightAsync( [ 1, 2, 3 ], add, [] ); // $ExpectError
71
- forEachRightAsync( [ 1, 2, 3 ], add, ( x: number ): number => x ); // $ExpectError
72
- }
73
-
74
- // The compiler throws an error if the function is provided an invalid number of arguments...
75
- {
76
- forEachRightAsync(); // $ExpectError
77
- forEachRightAsync( [ 1, 2, 3 ] ); // $ExpectError
78
- forEachRightAsync( [ 1, 2, 3 ], add ); // $ExpectError
79
- forEachRightAsync( [ 1, 2, 3 ], {}, add, done, {} ); // $ExpectError
80
- }
81
-
82
- // Attached to main export is a `factory` method which returns a function...
83
- {
84
- forEachRightAsync.factory( add ); // $ExpectType FactoryFunction
85
- forEachRightAsync.factory( { 'series': true }, add ); // $ExpectType FactoryFunction
86
- }
87
-
88
- // The compiler throws an error if the `factory` method is provided an options argument which is not an object...
89
- {
90
- forEachRightAsync.factory( [], add ); // $ExpectError
91
- forEachRightAsync.factory( 123, add ); // $ExpectError
92
- forEachRightAsync.factory( 'abc', add ); // $ExpectError
93
- forEachRightAsync.factory( false, add ); // $ExpectError
94
- forEachRightAsync.factory( true, add ); // $ExpectError
95
- }
96
-
97
- // The compiler throws an error if the `factory` method is provided a last argument which is not a function...
98
- {
99
- forEachRightAsync.factory( {} ); // $ExpectError
100
- forEachRightAsync.factory( true ); // $ExpectError
101
- forEachRightAsync.factory( false ); // $ExpectError
102
- forEachRightAsync.factory( {}, 123 ); // $ExpectError
103
- forEachRightAsync.factory( {}, 'abc' ); // $ExpectError
104
- }
105
-
106
- // The compiler throws an error if the function returned by the `factory` method is provided invalid arguments...
107
- {
108
- const fcn1 = forEachRightAsync.factory( add );
109
- fcn1( 12, done ); // $ExpectError
110
- fcn1( true, done ); // $ExpectError
111
- fcn1( false, done ); // $ExpectError
112
- fcn1( {}, done ); // $ExpectError
113
-
114
- fcn1( [ 1, 2, 3 ], 12 ); // $ExpectError
115
- fcn1( [ 1, 2, 3 ], true ); // $ExpectError
116
- fcn1( [ 1, 2, 3 ], false ); // $ExpectError
117
- fcn1( [ 1, 2, 3 ], '5' ); // $ExpectError
118
- fcn1( [ 1, 2, 3 ], {} ); // $ExpectError
119
- fcn1( [ 1, 2, 3 ], [] ); // $ExpectError
120
- fcn1( [ 1, 2, 3 ], ( x: number ): number => x ); // $ExpectError
121
- }
122
-
123
- // The compiler throws an error if the function returned by the `factory` method is provided an unsupported number of arguments...
124
- {
125
- const fcn1 = forEachRightAsync.factory( add );
126
- fcn1(); // $ExpectError
127
- fcn1( [ 1, 2, 3 ] ); // $ExpectError
128
- fcn1( [ 1, 2, 3 ], done, {} ); // $ExpectError
129
- }
130
-
131
- // The compiler throws an error if the `factory` method is provided a `limit` option which is not a number...
132
- {
133
- forEachRightAsync.factory( { 'limit': '12' }, add ); // $ExpectError
134
- forEachRightAsync.factory( { 'limit': true }, add ); // $ExpectError
135
- forEachRightAsync.factory( { 'limit': false }, add ); // $ExpectError
136
- forEachRightAsync.factory( { 'limit': {} }, add ); // $ExpectError
137
- forEachRightAsync.factory( { 'limit': [] }, add ); // $ExpectError
138
- forEachRightAsync.factory( { 'limit': ( x: number ): number => x }, add ); // $ExpectError
139
- }
140
-
141
- // The compiler throws an error if the `factory` method is provided a `series` option which is not a boolean...
142
- {
143
- forEachRightAsync.factory( { 'series': '12' }, add ); // $ExpectError
144
- forEachRightAsync.factory( { 'series': 12 }, add ); // $ExpectError
145
- forEachRightAsync.factory( { 'series': {} }, add ); // $ExpectError
146
- forEachRightAsync.factory( { 'series': [] }, add ); // $ExpectError
147
- forEachRightAsync.factory( { 'series': ( x: number ): number => x }, add ); // $ExpectError
148
- }
149
-
150
- // The compiler throws an error if the `factory` method is provided an invalid number of arguments...
151
- {
152
- forEachRightAsync.factory(); // $ExpectError
153
- forEachRightAsync.factory( {}, add, {} ); // $ExpectError
154
- }