@stdlib/utils-parallel 0.0.7 → 0.2.1
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 +30 -0
- package/LICENSE +0 -304
- package/NOTICE +1 -1
- package/README.md +50 -73
- package/dist/index.d.ts +3 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +2 -2
- package/lib/browser/index.js +1 -1
- package/lib/defaults.js +30 -18
- package/lib/index.js +2 -2
- package/lib/main.js +5 -5
- package/lib/node/exec.js +3 -2
- package/lib/node/worker/worker.js +1 -1
- package/lib/validate.js +9 -8
- package/package.json +17 -27
- package/bin/cli +0 -105
- package/docs/repl.txt +0 -68
- package/docs/types/test.ts +0 -164
- package/docs/usage.txt +0 -15
- package/etc/cli_opts.json +0 -23
package/docs/types/test.ts
DELETED
|
@@ -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