@stdlib/utils-async-inmap-right 0.0.7 → 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 +30 -0
- package/LICENSE +0 -304
- package/NOTICE +1 -1
- package/README.md +62 -13
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +25 -31
- package/lib/factory.js +4 -4
- package/lib/index.js +3 -3
- package/lib/limit.js +1 -1
- package/lib/{inmap_right.js → main.js} +0 -1
- package/lib/validate.js +4 -3
- package/package.json +20 -18
- package/docs/repl.txt +0 -209
- package/docs/types/test.ts +0 -149
package/docs/types/index.d.ts
CHANGED
|
@@ -16,43 +16,43 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/// <reference types="@stdlib/types"/>
|
|
22
22
|
|
|
23
|
-
import { Collection } from '@stdlib/types/
|
|
23
|
+
import { Collection } from '@stdlib/types/array';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Interface defining function options.
|
|
27
27
|
*/
|
|
28
|
-
interface Options {
|
|
28
|
+
interface Options<T, U, V> {
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Execution context.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
thisArg?: ThisParameterType<Fcn<T, U, V>>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* The maximum number of pending invocations at any one time.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
limit?: number;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Boolean indicating whether to sequentially invoke the provided function for each `collection` element. If `true`, the function sets `options.limit=1`. Default: false.
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
series?: boolean;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Callback invoked either upon processing all collection elements or upon encountering an error.
|
|
47
47
|
*/
|
|
48
|
-
type
|
|
48
|
+
type Nullary = () => void;
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Callback invoked either upon processing all collection elements or upon encountering an error.
|
|
52
52
|
*
|
|
53
53
|
* @param error - error argument
|
|
54
54
|
*/
|
|
55
|
-
type
|
|
55
|
+
type Unary = ( error: Error ) => void;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Callback invoked either upon processing all collection elements or upon encountering an error.
|
|
@@ -60,7 +60,7 @@ type DoneUnary = ( error: Error ) => void;
|
|
|
60
60
|
* @param error - error argument
|
|
61
61
|
* @param collection - updated input collection
|
|
62
62
|
*/
|
|
63
|
-
type
|
|
63
|
+
type Binary<U> = ( error: Error, collection: Collection<U> ) => void;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Callback invoked either upon processing all collection elements or upon encountering an error.
|
|
@@ -68,15 +68,14 @@ type DoneBinary = ( error: Error, collection: Collection ) => void;
|
|
|
68
68
|
* @param error - error argument
|
|
69
69
|
* @param collection - updated input collection
|
|
70
70
|
*/
|
|
71
|
-
type
|
|
71
|
+
type Callback<U> = Nullary | Unary | Binary<U>;
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Callback function.
|
|
75
75
|
*
|
|
76
76
|
* @param error - error argument
|
|
77
|
-
* @param result - value used to update the collection
|
|
78
77
|
*/
|
|
79
|
-
type
|
|
78
|
+
type UnaryNext = ( error: Error ) => void;
|
|
80
79
|
|
|
81
80
|
/**
|
|
82
81
|
* Callback function.
|
|
@@ -84,7 +83,7 @@ type Unary = ( error: Error ) => void;
|
|
|
84
83
|
* @param error - error argument
|
|
85
84
|
* @param result - value used to update the collection
|
|
86
85
|
*/
|
|
87
|
-
type
|
|
86
|
+
type BinaryNext<U> = ( error: Error | null, result: U ) => void;
|
|
88
87
|
|
|
89
88
|
/**
|
|
90
89
|
* Callback function.
|
|
@@ -92,7 +91,7 @@ type Binary = ( error: Error | null, result: any ) => void;
|
|
|
92
91
|
* @param error - error argument
|
|
93
92
|
* @param result - value used to update the collection
|
|
94
93
|
*/
|
|
95
|
-
type
|
|
94
|
+
type Next<U> = UnaryNext | BinaryNext<U>;
|
|
96
95
|
|
|
97
96
|
/**
|
|
98
97
|
* Function invoked for each element in a collection.
|
|
@@ -100,7 +99,7 @@ type Callback = Unary | Binary;
|
|
|
100
99
|
* @param value - collection value
|
|
101
100
|
* @param next - a callback to be invoked after processing a collection `value`
|
|
102
101
|
*/
|
|
103
|
-
type BinaryFcn = ( value:
|
|
102
|
+
type BinaryFcn<T, U, V> = ( this: V, value: T, next: Next<U> ) => void;
|
|
104
103
|
|
|
105
104
|
/**
|
|
106
105
|
* Function invoked for each element in a collection.
|
|
@@ -109,7 +108,7 @@ type BinaryFcn = ( value: any, next: Callback ) => void;
|
|
|
109
108
|
* @param index - collection index
|
|
110
109
|
* @param next - a callback to be invoked after processing a collection `value`
|
|
111
110
|
*/
|
|
112
|
-
type
|
|
111
|
+
type TernaryFcn<T, U, V> = ( this: V, value: T, index: number, next: Next<U> ) => void;
|
|
113
112
|
|
|
114
113
|
/**
|
|
115
114
|
* Function invoked for each element in a collection.
|
|
@@ -119,7 +118,7 @@ type TertiaryFcn = ( value: any, index: number, next: Callback ) => void;
|
|
|
119
118
|
* @param collection - input collection
|
|
120
119
|
* @param next - a callback to be invoked after processing a collection `value`
|
|
121
120
|
*/
|
|
122
|
-
type QuaternaryFcn = ( value:
|
|
121
|
+
type QuaternaryFcn<T, U, V> = ( this: V, value: T, index: number, collection: Collection<U>, next: Next<U> ) => void;
|
|
123
122
|
|
|
124
123
|
/**
|
|
125
124
|
* Function invoked for each element in a collection.
|
|
@@ -129,7 +128,7 @@ type QuaternaryFcn = ( value: any, index: number, collection: Collection, next:
|
|
|
129
128
|
* @param collection - input collection
|
|
130
129
|
* @param next - a callback to be invoked after processing a collection `value`
|
|
131
130
|
*/
|
|
132
|
-
type Fcn = BinaryFcn |
|
|
131
|
+
type Fcn<T, U, V> = BinaryFcn<T, U, V> | TernaryFcn<T, U, V> | QuaternaryFcn<T, U, V>;
|
|
133
132
|
|
|
134
133
|
/**
|
|
135
134
|
* Invokes the provided function for each element in a collection and updates a collection in-place.
|
|
@@ -137,7 +136,7 @@ type Fcn = BinaryFcn | TertiaryFcn | QuaternaryFcn;
|
|
|
137
136
|
* @param collection - input collection
|
|
138
137
|
* @param done - function to invoke upon completion
|
|
139
138
|
*/
|
|
140
|
-
type FactoryFunction = ( collection: Collection
|
|
139
|
+
type FactoryFunction<T, U> = ( collection: Collection<T>, done: Callback<U> ) => void;
|
|
141
140
|
|
|
142
141
|
/**
|
|
143
142
|
* Interface for `inmapRightAsync`.
|
|
@@ -151,7 +150,6 @@ interface InMapRightAsync {
|
|
|
151
150
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
152
151
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
153
152
|
*
|
|
154
|
-
*
|
|
155
153
|
* @param collection - input collection
|
|
156
154
|
* @param options - function options
|
|
157
155
|
* @param options.thisArg - execution context
|
|
@@ -192,7 +190,7 @@ interface InMapRightAsync {
|
|
|
192
190
|
*
|
|
193
191
|
* inmapRightAsync( files, {}, read, done );
|
|
194
192
|
*/
|
|
195
|
-
( collection: Collection
|
|
193
|
+
<T = unknown, U = unknown, V = unknown>( collection: Collection<T>, options: Options<T, U, V>, fcn: Fcn<T, U, V>, done: Callback<U> ): void;
|
|
196
194
|
|
|
197
195
|
/**
|
|
198
196
|
* Invokes a function once for each element in a collection and updates a collection in-place.
|
|
@@ -202,7 +200,6 @@ interface InMapRightAsync {
|
|
|
202
200
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
203
201
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
204
202
|
*
|
|
205
|
-
*
|
|
206
203
|
* @param collection - input collection
|
|
207
204
|
* @param fcn - function to invoke for each element in a collection
|
|
208
205
|
* @param done - function to invoke upon completion
|
|
@@ -238,7 +235,7 @@ interface InMapRightAsync {
|
|
|
238
235
|
*
|
|
239
236
|
* inmapRightAsync( files, read, done );
|
|
240
237
|
*/
|
|
241
|
-
( collection: Collection
|
|
238
|
+
<T = unknown, U = unknown, V = unknown>( collection: Collection<T>, fcn: Fcn<T, U, V>, done: Callback<U> ): void; // tslint:disable-line:no-unnecessary-generics
|
|
242
239
|
|
|
243
240
|
/**
|
|
244
241
|
* Returns a function to invoke a function once for each element in a collection and to update the collection in-place.
|
|
@@ -248,7 +245,6 @@ interface InMapRightAsync {
|
|
|
248
245
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
249
246
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
250
247
|
*
|
|
251
|
-
*
|
|
252
248
|
* @param options - function options
|
|
253
249
|
* @param options.thisArg - execution context
|
|
254
250
|
* @param options.limit - maximum number of pending invocations at any one time
|
|
@@ -298,7 +294,7 @@ interface InMapRightAsync {
|
|
|
298
294
|
* // Run `read` for each element in `files`:
|
|
299
295
|
* inmapRightAsync( files, done );
|
|
300
296
|
*/
|
|
301
|
-
factory( options: Options, fcn: Fcn ): FactoryFunction
|
|
297
|
+
factory<T = unknown, U = unknown, V = unknown>( options: Options<T, U, V>, fcn: Fcn<T, U, V> ): FactoryFunction<T, U>;
|
|
302
298
|
|
|
303
299
|
/**
|
|
304
300
|
* Returns a function to invoke a function once for each element in a collection and to update the collection in-place.
|
|
@@ -308,7 +304,6 @@ interface InMapRightAsync {
|
|
|
308
304
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
309
305
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
310
306
|
*
|
|
311
|
-
*
|
|
312
307
|
* @param fcn - function to invoke for each element in a collection
|
|
313
308
|
* @throws must provide valid options
|
|
314
309
|
* @returns function which invokes the provided function once for each element in a collection
|
|
@@ -350,7 +345,7 @@ interface InMapRightAsync {
|
|
|
350
345
|
* // Run `read` for each element in `files`:
|
|
351
346
|
* inmapRightAsync( files, done );
|
|
352
347
|
*/
|
|
353
|
-
factory( fcn: Fcn ): FactoryFunction
|
|
348
|
+
factory<T = unknown, U = unknown, V = unknown>( fcn: Fcn<T, U, V> ): FactoryFunction<T, U>; // tslint:disable-line:no-unnecessary-generics
|
|
354
349
|
}
|
|
355
350
|
|
|
356
351
|
/**
|
|
@@ -361,7 +356,6 @@ interface InMapRightAsync {
|
|
|
361
356
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
362
357
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
363
358
|
*
|
|
364
|
-
*
|
|
365
359
|
* @param collection - input collection
|
|
366
360
|
* @param options - function options
|
|
367
361
|
* @param options.thisArg - execution context
|
package/lib/factory.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
var isFunction = require( '@stdlib/assert-is-function' );
|
|
24
24
|
var isCollection = require( '@stdlib/assert-is-collection' );
|
|
25
|
+
var format = require( '@stdlib/string-format' );
|
|
25
26
|
var PINF = require( '@stdlib/constants-float64-pinf' );
|
|
26
27
|
var validate = require( './validate.js' );
|
|
27
28
|
var limit = require( './limit.js' );
|
|
@@ -37,7 +38,6 @@ var limit = require( './limit.js' );
|
|
|
37
38
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
38
39
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
39
40
|
*
|
|
40
|
-
*
|
|
41
41
|
* @param {Options} [options] - function options
|
|
42
42
|
* @param {*} [options.thisArg] - execution context
|
|
43
43
|
* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time
|
|
@@ -105,7 +105,7 @@ function factory( options, fcn ) {
|
|
|
105
105
|
f = options;
|
|
106
106
|
}
|
|
107
107
|
if ( !isFunction( f ) ) {
|
|
108
|
-
throw new TypeError( 'invalid argument. Last argument must be a function. Value:
|
|
108
|
+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );
|
|
109
109
|
}
|
|
110
110
|
if ( opts.series ) {
|
|
111
111
|
opts.limit = 1;
|
|
@@ -126,10 +126,10 @@ function factory( options, fcn ) {
|
|
|
126
126
|
*/
|
|
127
127
|
function inmapRightAsync( collection, done ) {
|
|
128
128
|
if ( !isCollection( collection ) ) {
|
|
129
|
-
throw new TypeError( 'invalid argument. First argument must be a collection. Value:
|
|
129
|
+
throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );
|
|
130
130
|
}
|
|
131
131
|
if ( !isFunction( done ) ) {
|
|
132
|
-
throw new TypeError( 'invalid argument. Last argument must be a function. Value:
|
|
132
|
+
throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );
|
|
133
133
|
}
|
|
134
134
|
return limit( collection, opts, f, clbk );
|
|
135
135
|
|
package/lib/index.js
CHANGED
|
@@ -60,15 +60,15 @@
|
|
|
60
60
|
// MODULES //
|
|
61
61
|
|
|
62
62
|
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
63
|
-
var
|
|
63
|
+
var main = require( './main.js' );
|
|
64
64
|
var factory = require( './factory.js' );
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
// MAIN //
|
|
68
68
|
|
|
69
|
-
setReadOnly(
|
|
69
|
+
setReadOnly( main, 'factory', factory );
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
// EXPORTS //
|
|
73
73
|
|
|
74
|
-
module.exports =
|
|
74
|
+
module.exports = main;
|
package/lib/limit.js
CHANGED
|
@@ -70,7 +70,7 @@ function limit( collection, opts, fcn, done ) {
|
|
|
70
70
|
for ( i = 0; i < lim; i++ ) {
|
|
71
71
|
// This guard is necessary to protect against synchronous functions which exhaust all collection elements...
|
|
72
72
|
if ( idx > 0 ) {
|
|
73
|
-
next(); // eslint-disable-line callback-return
|
|
73
|
+
next(); // eslint-disable-line node/callback-return
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
@@ -33,7 +33,6 @@ var factory = require( './factory.js' );
|
|
|
33
33
|
* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling. Note, however, that the function may have mutated an input collection during prior invocations, resulting in a partially mutated collection.
|
|
34
34
|
* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
36
|
* @param {Collection} collection - input collection
|
|
38
37
|
* @param {Options} [options] - function options
|
|
39
38
|
* @param {*} [options.thisArg] - execution context
|
package/lib/validate.js
CHANGED
|
@@ -24,6 +24,7 @@ var isObject = require( '@stdlib/assert-is-plain-object' );
|
|
|
24
24
|
var hasOwnProp = require( '@stdlib/assert-has-own-property' );
|
|
25
25
|
var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
|
|
26
26
|
var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;
|
|
27
|
+
var format = require( '@stdlib/string-format' );
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
// MAIN //
|
|
@@ -53,7 +54,7 @@ var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimit
|
|
|
53
54
|
*/
|
|
54
55
|
function validate( opts, options ) {
|
|
55
56
|
if ( !isObject( options ) ) {
|
|
56
|
-
return new TypeError( 'invalid argument. Options must be an object. Value:
|
|
57
|
+
return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
|
|
57
58
|
}
|
|
58
59
|
if ( hasOwnProp( options, 'thisArg' ) ) {
|
|
59
60
|
opts.thisArg = options.thisArg;
|
|
@@ -61,13 +62,13 @@ function validate( opts, options ) {
|
|
|
61
62
|
if ( hasOwnProp( options, 'series' ) ) {
|
|
62
63
|
opts.series = options.series;
|
|
63
64
|
if ( !isBoolean( opts.series ) ) {
|
|
64
|
-
return new TypeError( 'invalid option. `
|
|
65
|
+
return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'series', opts.series ) );
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
if ( hasOwnProp( options, 'limit' ) ) {
|
|
68
69
|
opts.limit = options.limit;
|
|
69
70
|
if ( !isPositiveInteger( opts.limit ) ) {
|
|
70
|
-
return new TypeError( 'invalid option. `
|
|
71
|
+
return new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'limit', opts.limit ) );
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/utils-async-inmap-right",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Invoke a function for each element in a collection and update the collection in-place, iterating from right to left.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,25 +37,27 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/assert-has-own-property": "^0.0
|
|
41
|
-
"@stdlib/assert-is-boolean": "^0.0
|
|
42
|
-
"@stdlib/assert-is-collection": "^0.0
|
|
43
|
-
"@stdlib/assert-is-function": "^0.0
|
|
44
|
-
"@stdlib/assert-is-plain-object": "^0.0
|
|
45
|
-
"@stdlib/assert-is-positive-integer": "^0.0
|
|
46
|
-
"@stdlib/constants-float64-pinf": "^0.0
|
|
47
|
-
"@stdlib/
|
|
48
|
-
"@stdlib/
|
|
49
|
-
"
|
|
40
|
+
"@stdlib/assert-has-own-property": "^0.1.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
|
|
53
|
-
"@stdlib/constants-float64-eps": "^0.0
|
|
54
|
-
"@stdlib/fs-read-file": "^0.0
|
|
55
|
-
"@stdlib/utils-noop": "^0.0
|
|
54
|
+
"@stdlib/bench": "^0.1.0",
|
|
55
|
+
"@stdlib/constants-float64-eps": "^0.1.0",
|
|
56
|
+
"@stdlib/fs-read-file": "^0.1.0",
|
|
57
|
+
"@stdlib/utils-noop": "^0.1.0",
|
|
56
58
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
57
59
|
"istanbul": "^0.4.1",
|
|
58
|
-
"tap-
|
|
60
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
59
61
|
},
|
|
60
62
|
"engines": {
|
|
61
63
|
"node": ">=0.10.0",
|
|
@@ -94,7 +96,7 @@
|
|
|
94
96
|
"async"
|
|
95
97
|
],
|
|
96
98
|
"funding": {
|
|
97
|
-
"type": "
|
|
98
|
-
"url": "https://
|
|
99
|
+
"type": "opencollective",
|
|
100
|
+
"url": "https://opencollective.com/stdlib"
|
|
99
101
|
}
|
|
100
102
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( collection, [options,] fcn, done )
|
|
3
|
-
Invokes a function once for each element in a collection and updates a
|
|
4
|
-
collection in-place, iterating from right to left.
|
|
5
|
-
|
|
6
|
-
When invoked, `fcn` is provided a maximum of four arguments:
|
|
7
|
-
|
|
8
|
-
- `value`: collection value
|
|
9
|
-
- `index`: collection index
|
|
10
|
-
- `collection`: the input collection
|
|
11
|
-
- `next`: a callback to be invoked after processing a collection `value`
|
|
12
|
-
|
|
13
|
-
The actual number of provided arguments depends on function length. If `fcn`
|
|
14
|
-
accepts two arguments, `fcn` is provided:
|
|
15
|
-
|
|
16
|
-
- `value`
|
|
17
|
-
- `next`
|
|
18
|
-
|
|
19
|
-
If `fcn` accepts three arguments, `fcn` is provided:
|
|
20
|
-
|
|
21
|
-
- `value`
|
|
22
|
-
- `index`
|
|
23
|
-
- `next`
|
|
24
|
-
|
|
25
|
-
For every other `fcn` signature, `fcn` is provided all four arguments.
|
|
26
|
-
|
|
27
|
-
The `next` callback accepts two arguments:
|
|
28
|
-
|
|
29
|
-
- `error`: error argument
|
|
30
|
-
- `result`: value used to update the collection
|
|
31
|
-
|
|
32
|
-
If a provided function calls the `next` callback with a truthy `error`
|
|
33
|
-
argument, the function suspends execution and immediately calls the `done`
|
|
34
|
-
callback for subsequent `error` handling. Note, however, that the function
|
|
35
|
-
may have mutated an input collection during prior invocations, resulting in
|
|
36
|
-
a partially mutated collection.
|
|
37
|
-
|
|
38
|
-
Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony,
|
|
39
|
-
wrap the `done` callback in a function which either executes at the end of
|
|
40
|
-
the current stack (e.g., `nextTick`) or during a subsequent turn of the
|
|
41
|
-
event loop (e.g., `setImmediate`, `setTimeout`).
|
|
42
|
-
|
|
43
|
-
The function does not support dynamic collection resizing.
|
|
44
|
-
|
|
45
|
-
The function does not skip `undefined` elements.
|
|
46
|
-
|
|
47
|
-
Parameters
|
|
48
|
-
----------
|
|
49
|
-
collection: Array|TypedArray|Object
|
|
50
|
-
Input collection over which to iterate. If provided an object, the
|
|
51
|
-
object must be array-like (excluding strings and functions).
|
|
52
|
-
|
|
53
|
-
options: Object (optional)
|
|
54
|
-
Function options.
|
|
55
|
-
|
|
56
|
-
options.limit: integer (optional)
|
|
57
|
-
Maximum number of pending invocations. Default: Infinity.
|
|
58
|
-
|
|
59
|
-
options.series: boolean (optional)
|
|
60
|
-
Boolean indicating whether to process each collection element
|
|
61
|
-
sequentially. Default: false.
|
|
62
|
-
|
|
63
|
-
options.thisArg: any (optional)
|
|
64
|
-
Execution context.
|
|
65
|
-
|
|
66
|
-
fcn: Function
|
|
67
|
-
The function to invoke for each element in a collection.
|
|
68
|
-
|
|
69
|
-
done: Function
|
|
70
|
-
A callback invoked either upon processing all collection elements or
|
|
71
|
-
upon encountering an error.
|
|
72
|
-
|
|
73
|
-
Examples
|
|
74
|
-
--------
|
|
75
|
-
// Basic usage:
|
|
76
|
-
> function fcn( value, index, next ) {
|
|
77
|
-
... setTimeout( onTimeout, value );
|
|
78
|
-
... function onTimeout() {
|
|
79
|
-
... console.log( value );
|
|
80
|
-
... next( null, value*index );
|
|
81
|
-
... }
|
|
82
|
-
... };
|
|
83
|
-
> function done( error, collection ) {
|
|
84
|
-
... if ( error ) {
|
|
85
|
-
... throw error;
|
|
86
|
-
... }
|
|
87
|
-
... console.log( collection === arr );
|
|
88
|
-
... console.log( collection );
|
|
89
|
-
... };
|
|
90
|
-
> var arr = [ 1000, 2500, 3000 ];
|
|
91
|
-
> {{alias}}( arr, fcn, done )
|
|
92
|
-
1000
|
|
93
|
-
2500
|
|
94
|
-
3000
|
|
95
|
-
true
|
|
96
|
-
[ 0, 2500, 6000 ]
|
|
97
|
-
|
|
98
|
-
// Limit number of concurrent invocations:
|
|
99
|
-
> function fcn( value, index, next ) {
|
|
100
|
-
... setTimeout( onTimeout, value );
|
|
101
|
-
... function onTimeout() {
|
|
102
|
-
... console.log( value );
|
|
103
|
-
... next( null, value*index );
|
|
104
|
-
... }
|
|
105
|
-
... };
|
|
106
|
-
> function done( error, collection ) {
|
|
107
|
-
... if ( error ) {
|
|
108
|
-
... throw error;
|
|
109
|
-
... }
|
|
110
|
-
... console.log( collection === arr );
|
|
111
|
-
... console.log( collection );
|
|
112
|
-
... };
|
|
113
|
-
> var opts = { 'limit': 2 };
|
|
114
|
-
> var arr = [ 1000, 2500, 3000 ];
|
|
115
|
-
> {{alias}}( arr, opts, fcn, done )
|
|
116
|
-
2500
|
|
117
|
-
3000
|
|
118
|
-
1000
|
|
119
|
-
true
|
|
120
|
-
[ 0, 2500, 6000 ]
|
|
121
|
-
|
|
122
|
-
// Process sequentially:
|
|
123
|
-
> function fcn( value, index, next ) {
|
|
124
|
-
... setTimeout( onTimeout, value );
|
|
125
|
-
... function onTimeout() {
|
|
126
|
-
... console.log( value );
|
|
127
|
-
... next( null, value*index );
|
|
128
|
-
... }
|
|
129
|
-
... };
|
|
130
|
-
> function done( error, collection ) {
|
|
131
|
-
... if ( error ) {
|
|
132
|
-
... throw error;
|
|
133
|
-
... }
|
|
134
|
-
... console.log( collection === arr );
|
|
135
|
-
... console.log( collection );
|
|
136
|
-
... };
|
|
137
|
-
> var opts = { 'series': true };
|
|
138
|
-
> var arr = [ 1000, 2500, 3000 ];
|
|
139
|
-
> {{alias}}( arr, opts, fcn, done )
|
|
140
|
-
3000
|
|
141
|
-
2500
|
|
142
|
-
1000
|
|
143
|
-
true
|
|
144
|
-
[ 0, 2500, 6000 ]
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
{{alias}}.factory( [options,] fcn )
|
|
148
|
-
Returns a function which invokes a function once for each element in a
|
|
149
|
-
collection and updates a collection in-place, iterating from right to left.
|
|
150
|
-
|
|
151
|
-
Parameters
|
|
152
|
-
----------
|
|
153
|
-
options: Object (optional)
|
|
154
|
-
Function options.
|
|
155
|
-
|
|
156
|
-
options.limit: integer (optional)
|
|
157
|
-
Maximum number of pending invocations. Default: Infinity.
|
|
158
|
-
|
|
159
|
-
options.series: boolean (optional)
|
|
160
|
-
Boolean indicating whether to process each collection element
|
|
161
|
-
sequentially. Default: false.
|
|
162
|
-
|
|
163
|
-
options.thisArg: any (optional)
|
|
164
|
-
Execution context.
|
|
165
|
-
|
|
166
|
-
fcn: Function
|
|
167
|
-
The function to invoke for each element in a collection.
|
|
168
|
-
|
|
169
|
-
Returns
|
|
170
|
-
-------
|
|
171
|
-
out: Function
|
|
172
|
-
A function which invokes a function for each element in a collection.
|
|
173
|
-
|
|
174
|
-
Examples
|
|
175
|
-
--------
|
|
176
|
-
> function fcn( value, index, next ) {
|
|
177
|
-
... setTimeout( onTimeout, value );
|
|
178
|
-
... function onTimeout() {
|
|
179
|
-
... console.log( value );
|
|
180
|
-
... next( null, value*index );
|
|
181
|
-
... }
|
|
182
|
-
... };
|
|
183
|
-
> var opts = { 'series': true };
|
|
184
|
-
> var f = {{alias}}.factory( opts, fcn );
|
|
185
|
-
> function done( error, collection ) {
|
|
186
|
-
... if ( error ) {
|
|
187
|
-
... throw error;
|
|
188
|
-
... }
|
|
189
|
-
... console.log( collection === arr );
|
|
190
|
-
... console.log( collection );
|
|
191
|
-
... };
|
|
192
|
-
> var arr = [ 1000, 2500, 3000 ];
|
|
193
|
-
> f( arr, done )
|
|
194
|
-
3000
|
|
195
|
-
2500
|
|
196
|
-
1000
|
|
197
|
-
true
|
|
198
|
-
[ 0, 2500, 6000 ]
|
|
199
|
-
> arr = [ 1000, 1500, 2000 ];
|
|
200
|
-
> f( arr, done )
|
|
201
|
-
2000
|
|
202
|
-
1500
|
|
203
|
-
1000
|
|
204
|
-
true
|
|
205
|
-
[ 0, 1500, 4000 ]
|
|
206
|
-
|
|
207
|
-
See Also
|
|
208
|
-
--------
|
|
209
|
-
|