@stdlib/utils-parallel 0.0.7 → 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/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
  # Parallel
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] -->
@@ -311,69 +322,16 @@ parallel( files, opts, done );
311
322
 
312
323
  <!-- /.examples -->
313
324
 
314
- * * *
315
-
316
- <section class="cli">
317
-
318
- ## CLI
319
-
320
- <section class="installation">
321
-
322
- ## Installation
323
-
324
- To use the module as a general utility, install the module globally
325
325
 
326
- ```bash
327
- npm install -g @stdlib/utils-parallel
328
- ```
329
-
330
- </section>
331
-
332
- <!-- CLI usage documentation. -->
333
-
334
- <section class="usage">
335
-
336
- ### Usage
337
-
338
- ```text
339
- Usage: parallel [options] <script1> <script2> ...
340
-
341
- Options:
342
-
343
- -h, --help Print this message.
344
- -V, --version Print the package version.
345
- --cmd cmd Executable file/command.
346
- --workers num Number of workers.
347
- --concurrency num Number of scripts to run concurrently.
348
- --ordered Preserve order of script output.
349
- --uid uid Process user identity.
350
- --gid gid Process group identity.
351
- --maxbuffer size Max buffer size for stdout and stderr.
352
- ```
353
-
354
- </section>
355
-
356
- <!-- /.usage -->
357
-
358
- <section class="examples">
359
326
 
360
- ### Examples
361
-
362
- ```bash
363
- $ parallel --cmd 'node' --workers 4 --concurrency 8 ./1.js ./2.js ./3.js ./4.js ./5.js ./6.js ./7.js ./8.js ./9.js ./10.js
364
- ```
365
-
366
- </section>
367
-
368
- <!-- /.examples -->
327
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
369
328
 
370
- </section>
329
+ <section class="related">
371
330
 
372
- <!-- /.cli -->
331
+ ## See Also
373
332
 
374
- <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
333
+ - <span class="package-name">[`@stdlib/utils-parallel-cli`][@stdlib/utils-parallel-cli]</span><span class="delimiter">: </span><span class="description">CLI package for use as a command-line utility.</span>
375
334
 
376
- <section class="related">
377
335
 
378
336
  </section>
379
337
 
@@ -405,7 +363,7 @@ See [LICENSE][stdlib-license].
405
363
 
406
364
  ## Copyright
407
365
 
408
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
366
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
409
367
 
410
368
  </section>
411
369
 
@@ -415,11 +373,13 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
415
373
 
416
374
  <section class="links">
417
375
 
376
+ [@stdlib/utils-parallel-cli]: https://www.npmjs.com/package/@stdlib/utils-parallel-cli
377
+
418
378
  [npm-image]: http://img.shields.io/npm/v/@stdlib/utils-parallel.svg
419
379
  [npm-url]: https://npmjs.org/package/@stdlib/utils-parallel
420
380
 
421
- [test-image]: https://github.com/stdlib-js/utils-parallel/actions/workflows/test.yml/badge.svg
422
- [test-url]: https://github.com/stdlib-js/utils-parallel/actions/workflows/test.yml
381
+ [test-image]: https://github.com/stdlib-js/utils-parallel/actions/workflows/test.yml/badge.svg?branch=v0.2.0
382
+ [test-url]: https://github.com/stdlib-js/utils-parallel/actions/workflows/test.yml?query=branch:v0.2.0
423
383
 
424
384
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-parallel/main.svg
425
385
  [coverage-url]: https://codecov.io/github/stdlib-js/utils-parallel?branch=main
@@ -431,19 +391,24 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
431
391
 
432
392
  -->
433
393
 
394
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
395
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
396
+
397
+ [stdlib]: https://github.com/stdlib-js/stdlib
398
+
399
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
400
+
401
+ [cli-section]: https://github.com/stdlib-js/utils-parallel#cli
402
+ [cli-url]: https://github.com/stdlib-js/utils-parallel/tree/cli
403
+ [@stdlib/utils-parallel]: https://github.com/stdlib-js/utils-parallel/tree/main
404
+
434
405
  [umd]: https://github.com/umdjs/umd
435
406
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
436
407
 
437
408
  [deno-url]: https://github.com/stdlib-js/utils-parallel/tree/deno
438
409
  [umd-url]: https://github.com/stdlib-js/utils-parallel/tree/umd
439
410
  [esm-url]: https://github.com/stdlib-js/utils-parallel/tree/esm
440
-
441
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
442
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
443
-
444
- [stdlib]: https://github.com/stdlib-js/stdlib
445
-
446
- [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
411
+ [branches-url]: https://github.com/stdlib-js/utils-parallel/blob/main/branches.md
447
412
 
448
413
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/utils-parallel/main/LICENSE
449
414
 
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import parallel from '../docs/types/index';
3
+ export = parallel;
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";var p=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var B=p(function(Rr,T){
2
+ var R=require('@stdlib/os-num-cpus/dist');function $(){return{workers:R-1,concurrency:R-1,cmd:"node",ordered:!1,uid:null,gid:null,encoding:"buffer",maxBuffer:200*1024*1024}}T.exports=$
3
+ });var K=p(function(Tr,I){
4
+ var rr=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-has-own-property/dist'),_=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,E=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,er=require('@stdlib/assert-is-boolean/dist').isPrimitive,ir=require('@stdlib/assert-is-string/dist').isPrimitive,v=require('@stdlib/error-tools-fmtprodmsg/dist');function nr(e,r){return rr(r)?w(r,"concurrency")&&(e.concurrency=r.concurrency,!_(e.concurrency))?new TypeError(v('1WZ3P',"concurrency",e.concurrency)):w(r,"workers")&&(e.workers=r.workers,!_(e.workers))?new TypeError(v('1WZ3P',"workers",e.workers)):w(r,"cmd")&&(e.cmd=r.cmd,!ir(e.cmd))?new TypeError(v('1WZ2W',"cmd",e.cmd)):w(r,"ordered")&&(e.ordered=r.ordered,!er(e.ordered))?new TypeError(v('1WZ2o',"ordered",e.ordered)):w(r,"uid")&&(e.uid=r.uid,!E(e.uid))?new TypeError(v('1WZ2t',"uid",e.uid)):w(r,"gid")&&(e.gid=r.gid,!E(e.gid))?new TypeError(v('1WZ2t',"gid",e.gid)):w(r,"maxBuffer")&&(e.maxBuffer=r.maxBuffer,!E(e.maxBuffer))?new TypeError(v('1WZ2t',"maxBuffer",e.maxBuffer)):null:new TypeError(v('1WZ2V',r));}I.exports=nr
5
+ });var W=p(function(Br,D){
6
+ var tr=require('@stdlib/utils-keys/dist'),P=require('@stdlib/process-env/dist');function ur(){var e,r,a,o;for(e=tr(P),a={},o=0;o<e.length;o++)r=e[o],a[r]=P[r];return a}function dr(e){var r=ur();return r.WORKER_CMD=e.cmd,r.WORKER_ENCODING=e.encoding,r.WORKER_MAX_BUFFER=e.maxBuffer,e.ordered&&(r.WORKER_ORDERED="1"),e.uid&&(r.WORKER_UID=e.uid),e.gid&&(r.WORKER_GID=e.gid),r}D.exports=dr
7
+ });var j=p(function(_r,N){
8
+ var ar=require('@stdlib/process-cwd/dist'),or=W();function cr(e){var r={cwd:ar(),env:or(e),stdio:"inherit"};return e.uid&&(r.uid=e.uid),e.gid&&(r.gid=e.gid),r}N.exports=cr
9
+ });var A=p(function(Ir,S){
10
+ var sr=require("child_process").fork,fr=require("path"),vr=require("debug"),O=require('@stdlib/utils-keys/dist'),F=require('@stdlib/error-tools-fmtprodmsg/dist'),lr=j(),u=vr("parallel:exec"),gr=fr.resolve(__dirname,"./worker/index.js");function mr(e,r,a){var o,c,l,f,y,d,x,k,g,h,m;for(u("Options: %s.",JSON.stringify(r)),o=0,u("Creating %d workers...",r.workers),c={},y=[],f=lr(r),m=0;m<r.workers;m++)u("Creating child process..."),d=sr(gr,y,f),d.on("error",Y(d)),d.on("close",L(d)),d.on("exit",z(d)),d.on("disconnect",Q(d)),d.on("message",J(d)),u("Child process created. pid: %d.",d.pid),c[d.pid]=d;for(x=O(c),u("%d workers created.",x.length),u("Running %d scripts concurrently...",r.concurrency),l={},g=-1,m=0;m<r.concurrency;m++)k=x[m%x.length],b(c[k]);function b(n){var t;if(g+=1,g>=e.length){if(t=O(l).length,t>0){u("%d scripts are pending.",t);return}return u("All scripts have finished."),q()}u("Instructing child process to run script: %s. pid: %d.",e[g],n.pid),n.send(e[g]),l[e[g]]=!0,u("%d of %d scripts have been processed.",g,e.length)}function J(n){return t;function t(i){u("Child process message: %s. pid: %d.",i,n.pid),delete l[i],b(n)}}function L(n){return t;function t(i,s){u("Child process closed. Code: %d. Signal: %s. pid: %d.",i,s,n.pid),C(i,s),X()}}function X(){o+=1,u("%d of %d child processes have closed.",o,r.workers),o===r.workers&&Z()}function z(n){return t;function t(i,s){u("Child process exited. Code: %d. Signal: %s. pid: %d.",i,s,n.pid),C(i,s)}}function q(n){var t,i,s;for(n&&!h&&(h=n),u("Instructing child processes to close..."),t=O(c),s=0;s<t.length;s++)i=t[s],u("Instructing child process (pid: %d) to close...",i),c[i].send("close")}function Q(n){return t;function t(){u("Child process disconnected. pid: %d.",n.pid)}}function Y(n){return t;function t(i){u("Child process error: %s. pid: %d.",i.message,n.pid),q(i)}}function C(n,t){var i;if(!h&&(n!==null&&n!==0?i=new Error(F('1WZBi',n)):t!==null&&(i=new Error(F('1WZBj',t))),i))return i.code=n,i.signal=t,q(i)}function Z(){if(h)return a(h);a()}}S.exports=mr
11
+ });var M=p(function(Kr,V){
12
+ var pr=A();V.exports=pr
13
+ });var H=p(function(Pr,G){
14
+ var wr=require("path"),hr=require('@stdlib/assert-is-string-array/dist').primitives,yr=require('@stdlib/assert-is-function/dist'),U=require('@stdlib/error-tools-fmtprodmsg/dist'),xr=require('@stdlib/process-cwd/dist'),qr=B(),Er=K(),Or=M();function kr(){var e,r,a,o,c,l,f;if(r=arguments[0],!hr(r))throw new TypeError(U('1WZ3s',r));if(r=r.slice(),a=qr(),arguments.length>2){if(e=arguments[1],o=arguments[2],c=Er(a,e),c)throw c}else o=arguments[1];if(!yr(o))throw new TypeError(U('1WZ2b',o));for(a.concurrency>r.length&&(a.concurrency=r.length),a.workers>a.concurrency&&(a.workers=a.concurrency),l=xr(),f=0;f<r.length;f++)r[f]=wr.resolve(l,r[f]);Or(r,a,y);function y(d){if(d)return o(d);o()}}G.exports=kr
15
+ });var br=H();module.exports=br;
16
+ /** @license Apache-2.0 */
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/defaults.js", "../lib/validate.js", "../lib/node/env.js", "../lib/node/options.js", "../lib/node/exec.js", "../lib/node/index.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 numCPUs = require( '@stdlib/os-num-cpus' );\n\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t// Number of workers:\n\t\t'workers': numCPUs - 1,\n\n\t\t// Number of scripts to execute concurrently:\n\t\t'concurrency': numCPUs - 1,\n\n\t\t// Executable file/command:\n\t\t'cmd': 'node',\n\n\t\t// Boolean indicating whether script output can be interleaved or must be ordered:\n\t\t'ordered': false,\n\n\t\t// Process user identity:\n\t\t'uid': null,\n\n\t\t// Process group identity:\n\t\t'gid': null,\n\n\t\t// `stdio` encoding:\n\t\t'encoding': 'buffer',\n\n\t\t// Max child process `stdio` buffer size:\n\t\t'maxBuffer': 200 * 1024 * 1024 // bytes\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = defaults;\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 isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).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 - options to validate\n* @param {string} [options.cmd] - executable file/command\n* @param {PositiveInteger} [options.concurrency] - number of scripts to execute concurrently\n* @param {PositiveInteger} [options.workers] - number of workers\n* @param {boolean} [options.ordered] - boolean indicating whether to preserve the order of script output\n* @param {NonNegativeInteger} [options.uid] - process user identity\n* @param {NonNegativeInteger} [options.gid] - process group identity\n* @param {NonNegativeInteger} [options.maxBuffer] - max child process `stdio` buffer size\n* @returns {(Error|null)} error or null\n*\n* @example\n* var opts = {};\n* var options = {\n* 'concurrency': 4,\n* 'workers': 2\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, 'concurrency' ) ) {\n\t\topts.concurrency = options.concurrency;\n\t\tif ( !isPositiveInteger( opts.concurrency ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'concurrency', opts.concurrency ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'workers' ) ) {\n\t\topts.workers = options.workers;\n\t\tif ( !isPositiveInteger( opts.workers ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'workers', opts.workers ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'cmd' ) ) {\n\t\topts.cmd = options.cmd;\n\t\tif ( !isString( opts.cmd ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'cmd', opts.cmd ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'ordered' ) ) {\n\t\topts.ordered = options.ordered;\n\t\tif ( !isBoolean( opts.ordered ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'ordered', opts.ordered ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'uid' ) ) {\n\t\topts.uid = options.uid;\n\t\tif ( !isNonNegativeInteger( opts.uid ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'uid', opts.uid ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'gid' ) ) {\n\t\topts.gid = options.gid;\n\t\tif ( !isNonNegativeInteger( opts.gid ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'gid', opts.gid ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'maxBuffer' ) ) {\n\t\topts.maxBuffer = options.maxBuffer;\n\t\tif ( !isNonNegativeInteger( opts.maxBuffer ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'maxBuffer', opts.maxBuffer ) );\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 objectKeys = require( '@stdlib/utils-keys' );\nvar ENV = require( '@stdlib/process-env' );\n\n\n// FUNCTIONS //\n\n/**\n* Copies `process.env`.\n*\n* ## Notes\n*\n* - This implementation accommodates `process.env` on older Node.js versions (<=v0.10.x), where `process.env` was object-like, but would show unexpected behavior when attempting to get own property descriptors.\n*\n* @private\n* @returns {Object} copy of `process.env`\n*/\nfunction copy() {\n\tvar keys;\n\tvar env;\n\tvar out;\n\tvar i;\n\n\tkeys = objectKeys( ENV );\n\tout = {};\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tenv = keys[ i ];\n\t\tout[ env ] = ENV[ env ];\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns worker environment variables.\n*\n* @private\n* @param {Options} opts - options\n* @param {string} opts.cmd - executable file/command\n* @param {boolean} opts.ordered - boolean indicating whether to preserve order of script output\n* @param {(NonNegativeInteger|null)} opts.uid - process user identity\n* @param {(NonNegativeInteger|null)} opts.gid - process group identity\n* @param {string} opts.encoding - `stdio` encoding\n* @param {NonNegativeInteger} opts.maxBuffer - max child process `stdio` buffer size\n* @returns {Object} environment variables\n*/\nfunction env( opts ) {\n\tvar out = copy();\n\n\tout.WORKER_CMD = opts.cmd;\n\tout.WORKER_ENCODING = opts.encoding;\n\tout.WORKER_MAX_BUFFER = opts.maxBuffer;\n\n\tif ( opts.ordered ) {\n\t\tout.WORKER_ORDERED = '1';\n\t}\n\tif ( opts.uid ) {\n\t\tout.WORKER_UID = opts.uid;\n\t}\n\tif ( opts.gid ) {\n\t\tout.WORKER_GID = opts.gid;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = env;\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 cwd = require( '@stdlib/process-cwd' );\nvar env = require( './env.js' );\n\n\n// MAIN //\n\n/**\n* Returns child process options.\n*\n* @private\n* @param {Options} options - worker options\n* @param {(NonNegativeInteger|null)} [options.uid] - process user identity\n* @param {(NonNegativeInteger|null)} [options.gid] - process group identity\n* @returns {Object} child process options\n*/\nfunction getOpts( options ) {\n\tvar opts = {\n\t\t'cwd': cwd(),\n\t\t'env': env( options ),\n\t\t'stdio': 'inherit' // Use stdio of parent process\n\t};\n\tif ( options.uid ) {\n\t\topts.uid = options.uid;\n\t}\n\tif ( options.gid ) {\n\t\topts.gid = options.gid;\n\t}\n\treturn opts;\n}\n\n\n// EXPORTS //\n\nmodule.exports = getOpts;\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 fork = require( 'child_process' ).fork;\nvar path = require( 'path' );\nvar logger = require( 'debug' );\nvar objectKeys = require( '@stdlib/utils-keys' );\nvar format = require( '@stdlib/string-format' );\nvar getOpts = require( './options.js' );\n\n\n// VARIABLES //\n\nvar debug = logger( 'parallel:exec' );\nvar WORKER_FILEPATH = path.resolve( __dirname, './worker/index.js' );\n\n\n// MAIN //\n\n/**\n* Executes scripts in parallel.\n*\n* @private\n* @param {StringArray} files - script absolute file paths\n* @param {Options} opts - options\n* @param {PositiveInteger} opts.concurrency - number of scripts to execute concurrently\n* @param {PositiveInteger} opts.workers - number of workers\n* @param {string} opts.cmd - executable file/command\n* @param {boolean} opts.ordered - boolean indicating whether to preserve order of script output\n* @param {(NonNegativeInteger|null)} opts.uid - process user identity\n* @param {(NonNegativeInteger|null)} opts.gid - process group identity\n* @param {string} opts.encoding - `stdio` encoding\n* @param {NonNegativeInteger} opts.maxBuffer - max child process `stdio` buffer size\n* @param {Callback} clbk - callback to invoke after executing all scripts\n*/\nfunction exec( files, opts, clbk ) {\n\tvar numClosed;\n\tvar workers;\n\tvar pending;\n\tvar fopts;\n\tvar args;\n\tvar proc;\n\tvar pids;\n\tvar pid;\n\tvar idx;\n\tvar err;\n\tvar i;\n\n\tdebug( 'Options: %s.', JSON.stringify( opts ) );\n\tnumClosed = 0;\n\n\tdebug( 'Creating %d workers...', opts.workers );\n\tworkers = {};\n\targs = [];\n\tfopts = getOpts( opts );\n\tfor ( i = 0; i < opts.workers; i++ ) {\n\t\tdebug( 'Creating child process...' );\n\t\tproc = fork( WORKER_FILEPATH, args, fopts );\n\n\t\tproc.on( 'error', onError( proc ) );\n\t\tproc.on( 'close', onClose( proc ) );\n\t\tproc.on( 'exit', onExit( proc ) );\n\t\tproc.on( 'disconnect', onDisconnect( proc ) );\n\t\tproc.on( 'message', onMessage( proc ) );\n\n\t\tdebug( 'Child process created. pid: %d.', proc.pid );\n\t\tworkers[ proc.pid ] = proc;\n\t}\n\tpids = objectKeys( workers );\n\tdebug( '%d workers created.', pids.length );\n\n\tdebug( 'Running %d scripts concurrently...', opts.concurrency );\n\tpending = {};\n\tidx = -1;\n\tfor ( i = 0; i < opts.concurrency; i++ ) {\n\t\tpid = pids[ i%pids.length ];\n\t\tnext( workers[ pid ] ); // eslint-disable-line node/callback-return\n\t}\n\n\t/**\n\t* Instructs a child process to run the next script.\n\t*\n\t* @private\n\t* @param {Object} child - child process\n\t* @returns {void}\n\t*/\n\tfunction next( child ) {\n\t\tvar numPending;\n\t\tidx += 1;\n\t\tif ( idx >= files.length ) {\n\t\t\tnumPending = objectKeys( pending ).length;\n\t\t\tif ( numPending > 0 ) {\n\t\t\t\tdebug( '%d scripts are pending.', numPending );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdebug( 'All scripts have finished.' );\n\t\t\treturn close();\n\t\t}\n\t\tdebug( 'Instructing child process to run script: %s. pid: %d.', files[ idx ], child.pid );\n\t\tchild.send( files[ idx ] );\n\t\tpending[ files[ idx ] ] = true;\n\n\t\tdebug( '%d of %d scripts have been processed.', idx, files.length );\n\t}\n\n\t/**\n\t* Returns a callback to be invoked upon receiving a message from a child process.\n\t*\n\t* @private\n\t* @param {Object} child - child process\n\t* @returns {Callback} callback\n\t*/\n\tfunction onMessage( child ) {\n\t\treturn listener;\n\n\t\t/**\n\t\t* Callback invoked upon receiving a message from a child process.\n\t\t*\n\t\t* @private\n\t\t* @param {string} filepath - script filepath\n\t\t*/\n\t\tfunction listener( filepath ) {\n\t\t\tdebug( 'Child process message: %s. pid: %d.', filepath, child.pid );\n\n\t\t\t// Remove the script from the listing of pending scripts:\n\t\t\tdelete pending[ filepath ];\n\n\t\t\t// Indicate that the child process is ready for its next task:\n\t\t\tnext( child );\n\t\t}\n\t}\n\n\t/**\n\t* Returns a callback to be invoked upon child process close.\n\t*\n\t* @private\n\t* @param {Object} child - child process\n\t* @returns {Callback} callback\n\t*/\n\tfunction onClose( child ) {\n\t\treturn listener;\n\n\t\t/**\n\t\t* Callback invoked upon child process close.\n\t\t*\n\t\t* @private\n\t\t* @param {(number|null)} code - exit code\n\t\t* @param {(string|null)} signal - termination signal\n\t\t*/\n\t\tfunction listener( code, signal ) {\n\t\t\tdebug( 'Child process closed. Code: %d. Signal: %s. pid: %d.', code, signal, child.pid );\n\t\t\tprocessExit( code, signal );\n\t\t\tchildClosed();\n\t\t}\n\t}\n\n\t/**\n\t* Callback invoked if a child closes.\n\t*\n\t* @private\n\t*/\n\tfunction childClosed() {\n\t\tnumClosed += 1;\n\t\tdebug( '%d of %d child processes have closed.', numClosed, opts.workers );\n\t\tif ( numClosed === opts.workers ) {\n\t\t\tdone(); // eslint-disable-line node/callback-return\n\t\t}\n\t}\n\n\t/**\n\t* Returns a callback to be invoked upon child process exit.\n\t*\n\t* @private\n\t* @param {Object} child - child process\n\t* @returns {Callback} callback\n\t*/\n\tfunction onExit( child ) {\n\t\treturn listener;\n\n\t\t/**\n\t\t* Callback invoked upon child process exit.\n\t\t*\n\t\t* @private\n\t\t* @param {(number|null)} code - exit code\n\t\t* @param {(string|null)} signal - termination signal\n\t\t*/\n\t\tfunction listener( code, signal ) {\n\t\t\tdebug( 'Child process exited. Code: %d. Signal: %s. pid: %d.', code, signal, child.pid );\n\t\t\tprocessExit( code, signal );\n\t\t}\n\t}\n\n\t/**\n\t* Closes all workers.\n\t*\n\t* @private\n\t* @param {Error} [error] - error object\n\t*/\n\tfunction close( error ) {\n\t\tvar pids;\n\t\tvar pid;\n\t\tvar i;\n\t\tif ( error && !err ) {\n\t\t\terr = error;\n\t\t}\n\t\tdebug( 'Instructing child processes to close...' );\n\t\tpids = objectKeys( workers );\n\t\tfor ( i = 0; i < pids.length; i++ ) {\n\t\t\tpid = pids[ i ];\n\t\t\tdebug( 'Instructing child process (pid: %d) to close...', pid );\n\t\t\tworkers[ pid ].send( 'close' );\n\t\t}\n\t}\n\n\t/**\n\t* Returns a callback to be invoked upon child process disconnect.\n\t*\n\t* @private\n\t* @param {Object} child - child process\n\t* @returns {Callback} callback\n\t*/\n\tfunction onDisconnect( child ) {\n\t\treturn listener;\n\n\t\t/**\n\t\t* Callback invoked upon child process disconnect.\n\t\t*\n\t\t* @private\n\t\t*/\n\t\tfunction listener() {\n\t\t\tdebug( 'Child process disconnected. pid: %d.', child.pid );\n\t\t}\n\t}\n\n\t/**\n\t* Returns a callback to be invoked upon encountering a child process error.\n\t*\n\t* @private\n\t* @param {Object} child - child process\n\t* @returns {Callback} callback\n\t*/\n\tfunction onError( child ) {\n\t\treturn listener;\n\n\t\t/**\n\t\t* Callback invoked upon a child process error.\n\t\t*\n\t\t* @private\n\t\t* @param {Error} error - error object\n\t\t*/\n\t\tfunction listener( error ) {\n\t\t\tdebug( 'Child process error: %s. pid: %d.', error.message, child.pid );\n\t\t\tclose( error );\n\t\t}\n\t}\n\n\t/**\n\t* Processes process exit values. If provided a non-zero exit code or termination signal, instructs the process to close.\n\t*\n\t* @private\n\t* @param {(number|null)} code - exit code\n\t* @param {(string|null)} signal - termination signal\n\t* @returns {void}\n\t*/\n\tfunction processExit( code, signal ) {\n\t\tvar error;\n\t\tif ( err ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( code !== null && code !== 0 ) {\n\t\t\terror = new Error( format( 'unexpected error. Child process failed with exit code: `%u`.', code ) );\n\t\t} else if ( signal !== null ) {\n\t\t\terror = new Error( format( 'unexpected error. Child process failed due to termination signal: `%s`.', signal ) );\n\t\t}\n\t\tif ( error ) {\n\t\t\terror.code = code;\n\t\t\terror.signal = signal;\n\t\t\treturn close( error );\n\t\t}\n\t}\n\n\t/**\n\t* Callback invoked once all tasks are finished.\n\t*\n\t* @private\n\t* @returns {void}\n\t*/\n\tfunction done() {\n\t\tif ( err ) {\n\t\t\treturn clbk( err );\n\t\t}\n\t\tclbk();\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = exec;\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// MAIN //\n\nvar exec = require( './exec.js' );\n\n\n// EXPORTS //\n\nmodule.exports = exec;\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 path = require( 'path' );\nvar isStringArray = require( '@stdlib/assert-is-string-array' ).primitives;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\nvar cwd = require( '@stdlib/process-cwd' );\nvar defaults = require( './defaults.js' );\nvar validate = require( './validate.js' );\nvar exec = require( './node' );\n\n\n// MAIN //\n\n/**\n* Executes scripts in parallel.\n*\n* @param {StringArray} files - script file paths\n* @param {Options} [options] - function options\n* @param {string} [options.cmd='node'] - executable file/command\n* @param {PositiveInteger} [options.concurrency] - number of scripts to execute concurrently\n* @param {PositiveInteger} [options.workers] - number of workers\n* @param {boolean} [options.ordered=false] - boolean indicating whether to preserve the order of script output\n* @param {NonNegativeInteger} [options.uid] - process user identity\n* @param {NonNegativeInteger} [options.gid] - process group identity\n* @param {NonNegativeInteger} [options.maxBuffer=200*1024*1024] - max child process `stdio` buffer size\n* @param {Callback} clbk - callback to invoke after executing all scripts\n* @throws {TypeError} first argument must be an array of strings\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} callback argument must be a function\n*\n* @example\n* var files = [ './a.js', './b.js ' ];\n*\n* var opts = {\n* 'workers': 3,\n* 'concurrency': 3\n* };\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* parallel( files, opts, done );\n*/\nfunction parallel() {\n\tvar options;\n\tvar files;\n\tvar opts;\n\tvar clbk;\n\tvar err;\n\tvar dir;\n\tvar i;\n\n\tfiles = arguments[ 0 ];\n\tif ( !isStringArray( files ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array of strings. Value: `%s`.', files ) );\n\t}\n\tfiles = files.slice();\n\topts = defaults();\n\tif ( arguments.length > 2 ) {\n\t\toptions = arguments[ 1 ];\n\t\tclbk = arguments[ 2 ];\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t} else {\n\t\tclbk = arguments[ 1 ];\n\t}\n\tif ( !isFunction( clbk ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t}\n\t// Prevent the number of concurrent scripts exceeding the number of actual scripts to run.\n\tif ( opts.concurrency > files.length ) {\n\t\topts.concurrency = files.length;\n\t}\n\t// Prevent the number of workers exceeding the number of concurrent scripts (excess capacity), as some workers would never be allocated scripts to run and always be idle.\n\tif ( opts.workers > opts.concurrency ) {\n\t\topts.workers = opts.concurrency;\n\t}\n\t// Resolve any relative paths to absolute paths...\n\tdir = cwd();\n\tfor ( i = 0; i < files.length; i++ ) {\n\t\tfiles[ i ] = path.resolve( dir, files[ i ] );\n\t}\n\texec( files, opts, done );\n\n\t/**\n\t* Callback invoked after executing all scripts.\n\t*\n\t* @private\n\t* @param {Error} error - error object\n\t* @returns {void}\n\t*/\n\tfunction done( error ) {\n\t\tif ( error ) {\n\t\t\treturn clbk( error );\n\t\t}\n\t\tclbk();\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = parallel;\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* Execute scripts in parallel.\n*\n* @module @stdlib/utils-parallel\n*\n* @example\n* var parallel = require( '@stdlib/utils-parallel' );\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;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AO,QAAUC,KC3BjB,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAO,QAAS,MAAO,EACvBC,GAAgB,QAAS,gCAAiC,EAAE,WAC5DC,GAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAC1CC,GAAM,QAAS,qBAAsB,EACrCC,GAAW,IACXC,GAAW,IACXC,GAAO,IAuCX,SAASC,IAAW,CACnB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAL,EAAQ,UAAW,CAAE,EAChB,CAACT,GAAeS,CAAM,EAC1B,MAAM,IAAI,UAAWP,EAAQ,6EAA8EO,CAAM,CAAE,EAIpH,GAFAA,EAAQA,EAAM,MAAM,EACpBC,EAAON,GAAS,EACX,UAAU,OAAS,GAIvB,GAHAI,EAAU,UAAW,CAAE,EACvBG,EAAO,UAAW,CAAE,EACpBC,EAAMP,GAAUK,EAAMF,CAAQ,EACzBI,EACJ,MAAMA,OAGPD,EAAO,UAAW,CAAE,EAErB,GAAK,CAACV,GAAYU,CAAK,EACtB,MAAM,IAAI,UAAWT,EAAQ,uEAAwES,CAAK,CAAE,EAY7G,IATKD,EAAK,YAAcD,EAAM,SAC7BC,EAAK,YAAcD,EAAM,QAGrBC,EAAK,QAAUA,EAAK,cACxBA,EAAK,QAAUA,EAAK,aAGrBG,EAAMV,GAAI,EACJW,EAAI,EAAGA,EAAIL,EAAM,OAAQK,IAC9BL,EAAOK,CAAE,EAAIf,GAAK,QAASc,EAAKJ,EAAOK,CAAE,CAAE,EAE5CR,GAAMG,EAAOC,EAAMK,CAAK,EASxB,SAASA,EAAMC,EAAQ,CACtB,GAAKA,EACJ,OAAOL,EAAMK,CAAM,EAEpBL,EAAK,CACN,CACD,CAKAb,EAAO,QAAUS,KC1FjB,IAAIU,GAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_defaults", "__commonJSMin", "exports", "module", "numCPUs", "defaults", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isPositiveInteger", "isNonNegativeInteger", "isBoolean", "isString", "format", "validate", "opts", "options", "require_env", "__commonJSMin", "exports", "module", "objectKeys", "ENV", "copy", "keys", "env", "out", "i", "opts", "require_options", "__commonJSMin", "exports", "module", "cwd", "env", "getOpts", "options", "opts", "require_exec", "__commonJSMin", "exports", "module", "fork", "path", "logger", "objectKeys", "format", "getOpts", "debug", "WORKER_FILEPATH", "exec", "files", "opts", "clbk", "numClosed", "workers", "pending", "fopts", "args", "proc", "pids", "pid", "idx", "err", "i", "onError", "onClose", "onExit", "onDisconnect", "onMessage", "next", "child", "numPending", "close", "listener", "filepath", "code", "signal", "processExit", "childClosed", "done", "error", "require_node", "__commonJSMin", "exports", "module", "exec", "require_main", "__commonJSMin", "exports", "module", "path", "isStringArray", "isFunction", "format", "cwd", "defaults", "validate", "exec", "parallel", "options", "files", "opts", "clbk", "err", "dir", "i", "done", "error", "main"]
7
+ }
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /**
22
22
  * Interface defining function options.
@@ -31,7 +31,7 @@
31
31
  */
32
32
  function runner() {
33
33
  // TODO: implementation
34
- throw new Error( 'not implemented. Please post an issue on the @stdlib/stdlib issue tracker if you would like this to be implemented.' );
34
+ throw new Error( 'not implemented. Please post an issue on the @stdlib/stdlib issue tracker if you would like this to be implemented. https://github.com/stdlib-js/stdlib/issues/new/choose' );
35
35
  }
36
36
 
37
37
 
package/lib/defaults.js CHANGED
@@ -25,31 +25,43 @@ var numCPUs = require( '@stdlib/os-num-cpus' );
25
25
 
26
26
  // MAIN //
27
27
 
28
- var defaults = {};
29
-
30
- // Number of workers:
31
- defaults.workers = numCPUs - 1;
28
+ /**
29
+ * Returns default options.
30
+ *
31
+ * @private
32
+ * @returns {Object} default options
33
+ *
34
+ * @example
35
+ * var o = defaults();
36
+ * // returns {...}
37
+ */
38
+ function defaults() {
39
+ return {
40
+ // Number of workers:
41
+ 'workers': numCPUs - 1,
32
42
 
33
- // Number of scripts to execute concurrently:
34
- defaults.concurrency = defaults.workers;
43
+ // Number of scripts to execute concurrently:
44
+ 'concurrency': numCPUs - 1,
35
45
 
36
- // Executable file/command:
37
- defaults.cmd = 'node';
46
+ // Executable file/command:
47
+ 'cmd': 'node',
38
48
 
39
- // Boolean indicating whether script output can be interleaved or must be ordered:
40
- defaults.ordered = false;
49
+ // Boolean indicating whether script output can be interleaved or must be ordered:
50
+ 'ordered': false,
41
51
 
42
- // Process user identity:
43
- defaults.uid = null;
52
+ // Process user identity:
53
+ 'uid': null,
44
54
 
45
- // Process group identity:
46
- defaults.gid = null;
55
+ // Process group identity:
56
+ 'gid': null,
47
57
 
48
- // `stdio` encoding:
49
- defaults.encoding = 'buffer';
58
+ // `stdio` encoding:
59
+ 'encoding': 'buffer',
50
60
 
51
- // Max child process `stdio` buffer size:
52
- defaults.maxBuffer = 200 * 1024 * 1024; // bytes
61
+ // Max child process `stdio` buffer size:
62
+ 'maxBuffer': 200 * 1024 * 1024 // bytes
63
+ };
64
+ }
53
65
 
54
66
 
55
67
  // EXPORTS //
package/lib/index.js CHANGED
@@ -37,9 +37,9 @@
37
37
 
38
38
  // MODULES //
39
39
 
40
- var parallel = require( './main.js' );
40
+ var main = require( './main.js' );
41
41
 
42
42
 
43
43
  // EXPORTS //
44
44
 
45
- module.exports = parallel;
45
+ module.exports = main;
package/lib/main.js CHANGED
@@ -23,8 +23,8 @@
23
23
  var path = require( 'path' );
24
24
  var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives;
25
25
  var isFunction = require( '@stdlib/assert-is-function' );
26
+ var format = require( '@stdlib/string-format' );
26
27
  var cwd = require( '@stdlib/process-cwd' );
27
- var copy = require( '@stdlib/utils-copy' );
28
28
  var defaults = require( './defaults.js' );
29
29
  var validate = require( './validate.js' );
30
30
  var exec = require( './node' );
@@ -45,7 +45,7 @@ var exec = require( './node' );
45
45
  * @param {NonNegativeInteger} [options.gid] - process group identity
46
46
  * @param {NonNegativeInteger} [options.maxBuffer=200*1024*1024] - max child process `stdio` buffer size
47
47
  * @param {Callback} clbk - callback to invoke after executing all scripts
48
- * @throws {TypeError} first argument must be a string array
48
+ * @throws {TypeError} first argument must be an array of strings
49
49
  * @throws {TypeError} options argument must be an object
50
50
  * @throws {TypeError} must provide valid options
51
51
  * @throws {TypeError} callback argument must be a function
@@ -77,10 +77,10 @@ function parallel() {
77
77
 
78
78
  files = arguments[ 0 ];
79
79
  if ( !isStringArray( files ) ) {
80
- throw new TypeError( 'invalid argument. First argument must be an array of string primitives. Value: `' + files + '`.' );
80
+ throw new TypeError( format( 'invalid argument. First argument must be an array of strings. Value: `%s`.', files ) );
81
81
  }
82
82
  files = files.slice();
83
- opts = copy( defaults );
83
+ opts = defaults();
84
84
  if ( arguments.length > 2 ) {
85
85
  options = arguments[ 1 ];
86
86
  clbk = arguments[ 2 ];
@@ -92,7 +92,7 @@ function parallel() {
92
92
  clbk = arguments[ 1 ];
93
93
  }
94
94
  if ( !isFunction( clbk ) ) {
95
- throw new TypeError( 'invalid argument. Callback argument must be a function. Value: `' + clbk + '`.' );
95
+ throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
96
96
  }
97
97
  // Prevent the number of concurrent scripts exceeding the number of actual scripts to run.
98
98
  if ( opts.concurrency > files.length ) {
package/lib/node/exec.js CHANGED
@@ -24,6 +24,7 @@ var fork = require( 'child_process' ).fork;
24
24
  var path = require( 'path' );
25
25
  var logger = require( 'debug' );
26
26
  var objectKeys = require( '@stdlib/utils-keys' );
27
+ var format = require( '@stdlib/string-format' );
27
28
  var getOpts = require( './options.js' );
28
29
 
29
30
 
@@ -286,9 +287,9 @@ function exec( files, opts, clbk ) {
286
287
  return;
287
288
  }
288
289
  if ( code !== null && code !== 0 ) {
289
- error = new Error( 'Child process failed with exit code: '+code+'.' );
290
+ error = new Error( format( 'unexpected error. Child process failed with exit code: `%u`.', code ) );
290
291
  } else if ( signal !== null ) {
291
- error = new Error( 'Child process failed due to termination signal: '+signal+'.' );
292
+ error = new Error( format( 'unexpected error. Child process failed due to termination signal: `%s`.', signal ) );
292
293
  }
293
294
  if ( error ) {
294
295
  error.code = code;
package/lib/validate.js CHANGED
@@ -26,6 +26,7 @@ var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimit
26
26
  var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;
27
27
  var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
28
28
  var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
29
+ var format = require( '@stdlib/string-format' );
29
30
 
30
31
 
31
32
  // MAIN //
@@ -58,48 +59,48 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
58
59
  */
59
60
  function validate( opts, options ) {
60
61
  if ( !isObject( options ) ) {
61
- return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' );
62
+ return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
62
63
  }
63
64
  if ( hasOwnProp( options, 'concurrency' ) ) {
64
65
  opts.concurrency = options.concurrency;
65
66
  if ( !isPositiveInteger( opts.concurrency ) ) {
66
- return new TypeError( 'invalid option. `concurrency` option must be a positive integer. Option: `' + opts.concurrency + '`.' );
67
+ return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'concurrency', opts.concurrency ) );
67
68
  }
68
69
  }
69
70
  if ( hasOwnProp( options, 'workers' ) ) {
70
71
  opts.workers = options.workers;
71
72
  if ( !isPositiveInteger( opts.workers ) ) {
72
- return new TypeError( 'invalid option. `workers` option must be a positive integer. Option: `' + opts.workers + '`.' );
73
+ return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'workers', opts.workers ) );
73
74
  }
74
75
  }
75
76
  if ( hasOwnProp( options, 'cmd' ) ) {
76
77
  opts.cmd = options.cmd;
77
78
  if ( !isString( opts.cmd ) ) {
78
- return new TypeError( 'invalid option. `cmd` option must be a primitive string. Option: `' + opts.cmd + '`.' );
79
+ return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'cmd', opts.cmd ) );
79
80
  }
80
81
  }
81
82
  if ( hasOwnProp( options, 'ordered' ) ) {
82
83
  opts.ordered = options.ordered;
83
84
  if ( !isBoolean( opts.ordered ) ) {
84
- return new TypeError( 'invalid option. `ordered` option must be a primitive boolean. Option: `' + opts.ordered + '`.' );
85
+ return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'ordered', opts.ordered ) );
85
86
  }
86
87
  }
87
88
  if ( hasOwnProp( options, 'uid' ) ) {
88
89
  opts.uid = options.uid;
89
90
  if ( !isNonNegativeInteger( opts.uid ) ) {
90
- return new TypeError( 'invalid option. `uid` option must be a nonnegative integer. Option: `' + opts.uid + '`.' );
91
+ return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'uid', opts.uid ) );
91
92
  }
92
93
  }
93
94
  if ( hasOwnProp( options, 'gid' ) ) {
94
95
  opts.gid = options.gid;
95
96
  if ( !isNonNegativeInteger( opts.gid ) ) {
96
- return new TypeError( 'invalid option. `gid` option must be a nonnegative integer. Option: `' + opts.gid + '`.' );
97
+ return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'gid', opts.gid ) );
97
98
  }
98
99
  }
99
100
  if ( hasOwnProp( options, 'maxBuffer' ) ) {
100
101
  opts.maxBuffer = options.maxBuffer;
101
102
  if ( !isNonNegativeInteger( opts.maxBuffer ) ) {
102
- return new TypeError( 'invalid option. `maxBuffer` option must be a nonnegative integer. Option: `' + opts.maxBuffer + '`.' );
103
+ return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'maxBuffer', opts.maxBuffer ) );
103
104
  }
104
105
  }
105
106
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/utils-parallel",
3
- "version": "0.0.7",
3
+ "version": "0.2.0",
4
4
  "description": "Execute scripts in parallel.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -13,9 +13,6 @@
13
13
  "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
14
  }
15
15
  ],
16
- "bin": {
17
- "parallel": "./bin/cli"
18
- },
19
16
  "main": "./lib",
20
17
  "browser": {
21
18
  "./lib": "./lib/browser/index.js",
@@ -42,33 +39,23 @@
42
39
  "url": "https://github.com/stdlib-js/stdlib/issues"
43
40
  },
44
41
  "dependencies": {
45
- "@stdlib/assert-has-own-property": "^0.0.x",
46
- "@stdlib/assert-is-boolean": "^0.0.x",
47
- "@stdlib/assert-is-function": "^0.0.x",
48
- "@stdlib/assert-is-nonnegative-integer": "^0.0.x",
49
- "@stdlib/assert-is-plain-object": "^0.0.x",
50
- "@stdlib/assert-is-positive-integer": "^0.0.x",
51
- "@stdlib/assert-is-string": "^0.0.x",
52
- "@stdlib/assert-is-string-array": "^0.0.x",
53
- "@stdlib/cli-ctor": "^0.0.x",
54
- "@stdlib/fs-read-file": "^0.0.x",
55
- "@stdlib/os-num-cpus": "^0.0.x",
56
- "@stdlib/process-cwd": "^0.0.x",
57
- "@stdlib/process-env": "^0.0.x",
58
- "@stdlib/utils-copy": "^0.0.x",
59
- "@stdlib/utils-keys": "^0.0.x",
60
- "debug": "^2.6.9"
42
+ "@stdlib/assert-has-own-property": "^0.1.0",
43
+ "@stdlib/assert-is-boolean": "^0.1.0",
44
+ "@stdlib/assert-is-function": "^0.1.0",
45
+ "@stdlib/assert-is-nonnegative-integer": "^0.1.0",
46
+ "@stdlib/assert-is-plain-object": "^0.1.0",
47
+ "@stdlib/assert-is-positive-integer": "^0.1.0",
48
+ "@stdlib/assert-is-string": "^0.1.0",
49
+ "@stdlib/assert-is-string-array": "^0.1.0",
50
+ "@stdlib/os-num-cpus": "^0.1.0",
51
+ "@stdlib/process-cwd": "^0.1.0",
52
+ "@stdlib/string-format": "^0.1.0"
61
53
  },
62
54
  "devDependencies": {
63
- "@stdlib/fs-unlink": "^0.0.x",
64
- "@stdlib/fs-write-file": "^0.0.x",
65
- "@stdlib/random-base-minstd": "^0.0.x",
66
- "@stdlib/utils-next-tick": "^0.0.x",
67
- "@stdlib/utils-noop": "^0.0.x",
68
55
  "proxyquire": "^2.0.0",
69
56
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
70
57
  "istanbul": "^0.4.1",
71
- "tap-spec": "5.x.x"
58
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
72
59
  },
73
60
  "engines": {
74
61
  "node": ">=0.10.0",
@@ -114,7 +101,7 @@
114
101
  ],
115
102
  "__stdlib__": {},
116
103
  "funding": {
117
- "type": "patreon",
118
- "url": "https://www.patreon.com/athan"
104
+ "type": "opencollective",
105
+ "url": "https://opencollective.com/stdlib"
119
106
  }
120
107
  }
package/bin/cli DELETED
@@ -1,105 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * @license Apache-2.0
5
- *
6
- * Copyright (c) 2018 The Stdlib Authors.
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
11
- *
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
- 'use strict';
22
-
23
- // MODULES //
24
-
25
- var resolve = require( 'path' ).resolve;
26
- var readFileSync = require( '@stdlib/fs-read-file' ).sync;
27
- var CLI = require( '@stdlib/cli-ctor' );
28
- var parallel = require( './../lib' );
29
-
30
-
31
- // FUNCTIONS //
32
-
33
- /**
34
- * Callback invoked upon executing all scripts.
35
- *
36
- * @private
37
- * @param {Error} [error] - error object
38
- * @throws {Error} unexpected error
39
- */
40
- function done( error ) {
41
- if ( error ) {
42
- throw error;
43
- }
44
- }
45
-
46
-
47
- // MAIN //
48
-
49
- /**
50
- * Main execution sequence.
51
- *
52
- * @private
53
- */
54
- function main() {
55
- var flags;
56
- var args;
57
- var opts;
58
- var cli;
59
-
60
- // Create a command-line interface:
61
- cli = new CLI({
62
- 'pkg': require( './../package.json' ),
63
- 'options': require( './../etc/cli_opts.json' ),
64
- 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
65
- 'encoding': 'utf8'
66
- })
67
- });
68
-
69
- // Get any provided command-line options:
70
- flags = cli.flags();
71
- if ( flags.help || flags.version ) {
72
- return;
73
- }
74
-
75
- // Get any command-line arguments:
76
- args = cli.args();
77
-
78
- opts = {};
79
- if ( flags.cmd ) {
80
- opts.cmd = flags.cmd;
81
- }
82
- if ( flags.workers ) {
83
- opts.workers = parseInt( flags.workers, 10 );
84
- }
85
- if ( flags.concurrency ) {
86
- opts.concurrency = parseInt( flags.concurrency, 10 );
87
- }
88
- if ( flags.ordered ) {
89
- opts.ordered = flags.ordered;
90
- }
91
- if ( flags.uid ) {
92
- opts.uid = parseInt( flags.uid, 10 );
93
- }
94
- if ( flags.gid ) {
95
- opts.gid = parseInt( flags.gid, 10 );
96
- }
97
- if ( flags.maxbuffer ) {
98
- opts.maxBuffer = parseInt( flags.maxbuffer, 10 );
99
- }
100
-
101
- // Run main:
102
- parallel( args, opts, done );
103
- }
104
-
105
- main();
package/docs/repl.txt DELETED
@@ -1,68 +0,0 @@
1
-
2
- {{alias}}( files, [options,] clbk )
3
- Executes scripts in parallel.
4
-
5
- Relative file paths are resolved relative to the current working directory.
6
-
7
- Ordered script output does not imply that scripts are executed in order. To
8
- preserve script order, execute the scripts sequentially via some other
9
- means.
10
-
11
- Parameters
12
- ----------
13
- files: Array<string>
14
- Script file paths.
15
-
16
- options: Object (optional)
17
- Options.
18
-
19
- options.cmd: string (optional)
20
- Executable file/command. Default: `'node'`.
21
-
22
- options.concurrency: integer (optional)
23
- Number of scripts to execute concurrently. Script concurrency cannot
24
- exceed the number of scripts. By specifying a concurrency greater than
25
- the number of workers, a worker may be executing more than `1` script at
26
- any one time. While not likely to be advantageous for synchronous
27
- scripts, setting a higher concurrency may be advantageous for scripts
28
- performing asynchronous tasks. If the script concurrency is less than
29
- the number of workers, the number of workers is reduced to match the
30
- specified concurrency. Default: `options.workers`.
31
-
32
- options.workers: integer (optional)
33
- Number of workers. Default: number of CPUs minus `1`.
34
-
35
- options.ordered: boolean (optional)
36
- Boolean indicating whether to preserve the order of script output. By
37
- default, the `stdio` output for each script is interleaved; i.e., the
38
- `stdio` output from one script may be interleaved with the `stdio`
39
- output from one or more other scripts. To preserve the `stdio` output
40
- order for each script, set the `ordered` option to `true`. Default:
41
- `false`.
42
-
43
- options.uid: integer (optional)
44
- Process user identity.
45
-
46
- options.gid: integer (optional)
47
- Process group identity.
48
-
49
- options.maxBuffer: integer (optional)
50
- Max child process `stdio` buffer size. This option is only applied when
51
- `options.ordered = true`. Default: `200*1024*1024`.
52
-
53
- clbk: Function
54
- Callback to invoke after executing all scripts.
55
-
56
- Examples
57
- --------
58
- > function done( error ) { if ( error ) { throw error; } };
59
- > var files = [ './a.js', './b.js' ];
60
- > {{alias}}( files, done );
61
-
62
- // Specify the number of workers:
63
- > var opts = { 'workers': 8 };
64
- > {{alias}}( files, opts, done );
65
-
66
- See Also
67
- --------
68
-
@@ -1,164 +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 parallel = require( './index' );
20
-
21
- const done = ( error: Error ) => {
22
- if ( error ) {
23
- throw error;
24
- }
25
- };
26
-
27
- // TESTS //
28
-
29
- // The function returns an array of indices, element values, or arrays of index-value pairs...
30
- {
31
- const files = [ './a.js', './b.js ' ];
32
- parallel( files, done );
33
- }
34
-
35
- // The compiler throws an error if the function is provided a first argument which is not an array of strings...
36
- {
37
- parallel( 'abc', done ); // $ExpectError
38
- parallel( {}, done ); // $ExpectError
39
- parallel( null, done ); // $ExpectError
40
- parallel( true, done ); // $ExpectError
41
- parallel( false, done ); // $ExpectError
42
- parallel( 5, done ); // $ExpectError
43
- parallel( ( x: number ): number => x, done ); // $ExpectError
44
- }
45
-
46
- // The compiler throws an error if the function is provided a last argument which is not a function...
47
- {
48
- const files = [ './a.js', './b.js ' ];
49
- parallel( files, false ); // $ExpectError
50
- parallel( files, true ); // $ExpectError
51
- parallel( files, 32 ); // $ExpectError
52
- parallel( files, 'abc' ); // $ExpectError
53
- parallel( files, [] ); // $ExpectError
54
- parallel( files, {} ); // $ExpectError
55
-
56
- parallel( files, {}, false ); // $ExpectError
57
- parallel( files, {}, true ); // $ExpectError
58
- parallel( files, {}, 32 ); // $ExpectError
59
- parallel( files, {}, 'abc' ); // $ExpectError
60
- parallel( files, {}, [] ); // $ExpectError
61
- parallel( files, {}, {} ); // $ExpectError
62
- }
63
-
64
- // The compiler throws an error if the function is provided an options argument which is not an object...
65
- {
66
- const files = [ './a.js', './b.js ' ];
67
- parallel( files, null, done ); // $ExpectError
68
- parallel( files, 123, done ); // $ExpectError
69
- parallel( files, false, done ); // $ExpectError
70
- parallel( files, true, done ); // $ExpectError
71
- parallel( files, [], done ); // $ExpectError
72
- parallel( files, ( x: number ): number => x, done ); // $ExpectError
73
- }
74
-
75
- // The compiler throws an error if the function is provided a `cmd` option which is not a string...
76
- {
77
- const files = [ './a.js', './b.js ' ];
78
- parallel( files, { 'cmd': false }, done ); // $ExpectError
79
- parallel( files, { 'cmd': true }, done ); // $ExpectError
80
- parallel( files, { 'cmd': null }, done ); // $ExpectError
81
- parallel( files, { 'cmd': 123 }, done ); // $ExpectError
82
- parallel( files, { 'cmd': [] }, done ); // $ExpectError
83
- parallel( files, { 'cmd': {} }, done ); // $ExpectError
84
- parallel( files, { 'cmd': ( x: number ): number => x }, done ); // $ExpectError
85
- }
86
-
87
- // The compiler throws an error if the function is provided a `workers` option which is not a number...
88
- {
89
- const files = [ './a.js', './b.js ' ];
90
- parallel( files, { 'workers': 'abc' }, done ); // $ExpectError
91
- parallel( files, { 'workers': false }, done ); // $ExpectError
92
- parallel( files, { 'workers': true }, done ); // $ExpectError
93
- parallel( files, { 'workers': null }, done ); // $ExpectError
94
- parallel( files, { 'workers': [] }, done ); // $ExpectError
95
- parallel( files, { 'workers': {} }, done ); // $ExpectError
96
- parallel( files, { 'workers': ( x: number ): number => x }, done ); // $ExpectError
97
- }
98
-
99
- // The compiler throws an error if the function is provided a `concurrency` option which is not a number...
100
- {
101
- const files = [ './a.js', './b.js ' ];
102
- parallel( files, { 'concurrency': 'abc' }, done ); // $ExpectError
103
- parallel( files, { 'concurrency': false }, done ); // $ExpectError
104
- parallel( files, { 'concurrency': true }, done ); // $ExpectError
105
- parallel( files, { 'concurrency': null }, done ); // $ExpectError
106
- parallel( files, { 'concurrency': [] }, done ); // $ExpectError
107
- parallel( files, { 'concurrency': {} }, done ); // $ExpectError
108
- parallel( files, { 'concurrency': ( x: number ): number => x }, done ); // $ExpectError
109
- }
110
-
111
- // The compiler throws an error if the function is provided a `ordered` option which is not a boolean...
112
- {
113
- const files = [ './a.js', './b.js ' ];
114
- parallel( files, { 'ordered': 'abc' }, done ); // $ExpectError
115
- parallel( files, { 'ordered': 123 }, done ); // $ExpectError
116
- parallel( files, { 'ordered': null }, done ); // $ExpectError
117
- parallel( files, { 'ordered': [] }, done ); // $ExpectError
118
- parallel( files, { 'ordered': {} }, done ); // $ExpectError
119
- parallel( files, { 'ordered': ( x: number ): number => x }, done ); // $ExpectError
120
- }
121
-
122
- // The compiler throws an error if the function is provided a `uid` option which is not a number...
123
- {
124
- const files = [ './a.js', './b.js ' ];
125
- parallel( files, { 'uid': 'abc' }, done ); // $ExpectError
126
- parallel( files, { 'uid': false }, done ); // $ExpectError
127
- parallel( files, { 'uid': true }, done ); // $ExpectError
128
- parallel( files, { 'uid': null }, done ); // $ExpectError
129
- parallel( files, { 'uid': [] }, done ); // $ExpectError
130
- parallel( files, { 'uid': {} }, done ); // $ExpectError
131
- parallel( files, { 'uid': ( x: number ): number => x }, done ); // $ExpectError
132
- }
133
-
134
- // The compiler throws an error if the function is provided a `gid` option which is not a number...
135
- {
136
- const files = [ './a.js', './b.js ' ];
137
- parallel( files, { 'gid': 'abc' }, done ); // $ExpectError
138
- parallel( files, { 'gid': false }, done ); // $ExpectError
139
- parallel( files, { 'gid': true }, done ); // $ExpectError
140
- parallel( files, { 'gid': null }, done ); // $ExpectError
141
- parallel( files, { 'gid': [] }, done ); // $ExpectError
142
- parallel( files, { 'gid': {} }, done ); // $ExpectError
143
- parallel( files, { 'gid': ( x: number ): number => x }, done ); // $ExpectError
144
- }
145
-
146
- // The compiler throws an error if the function is provided a `maxBuffer` option which is not a number...
147
- {
148
- const files = [ './a.js', './b.js ' ];
149
- parallel( files, { 'maxBuffer': 'abc' }, done ); // $ExpectError
150
- parallel( files, { 'maxBuffer': false }, done ); // $ExpectError
151
- parallel( files, { 'maxBuffer': true }, done ); // $ExpectError
152
- parallel( files, { 'maxBuffer': null }, done ); // $ExpectError
153
- parallel( files, { 'maxBuffer': [] }, done ); // $ExpectError
154
- parallel( files, { 'maxBuffer': {} }, done ); // $ExpectError
155
- parallel( files, { 'maxBuffer': ( x: number ): number => x }, done ); // $ExpectError
156
- }
157
-
158
- // The compiler throws an error if the function is provided an invalid number of arguments...
159
- {
160
- const files = [ './a.js', './b.js ' ];
161
- parallel(); // $ExpectError
162
- parallel( files ); // $ExpectError
163
- parallel( files, {}, done, 16 ); // $ExpectError
164
- }
package/docs/usage.txt DELETED
@@ -1,15 +0,0 @@
1
-
2
- Usage: parallel [options] <script1> <script2> ...
3
-
4
- Options:
5
-
6
- -h, --help Print this message.
7
- -V, --version Print the package version.
8
- --cmd cmd Executable file/command.
9
- --workers num Number of workers.
10
- --concurrency num Number of scripts to run concurrently.
11
- --ordered Preserve order of script output.
12
- --uid uid Process user identity.
13
- --gid gid Process group identity.
14
- --maxbuffer size Max buffer size for stdout and stderr.
15
-
package/etc/cli_opts.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "string": [
3
- "cmd",
4
- "workers",
5
- "concurrency",
6
- "uid",
7
- "gid",
8
- "maxbuffer"
9
- ],
10
- "boolean": [
11
- "help",
12
- "version",
13
- "ordered"
14
- ],
15
- "alias": {
16
- "help": [
17
- "h"
18
- ],
19
- "version": [
20
- "V"
21
- ]
22
- }
23
- }