@stdlib/utils-async-for-each 0.2.1 → 0.2.3

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/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -389,7 +389,7 @@ See [LICENSE][stdlib-license].
389
389
 
390
390
  ## Copyright
391
391
 
392
- Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
392
+ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
393
393
 
394
394
  </section>
395
395
 
@@ -402,8 +402,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
402
402
  [npm-image]: http://img.shields.io/npm/v/@stdlib/utils-async-for-each.svg
403
403
  [npm-url]: https://npmjs.org/package/@stdlib/utils-async-for-each
404
404
 
405
- [test-image]: https://github.com/stdlib-js/utils-async-for-each/actions/workflows/test.yml/badge.svg?branch=v0.2.1
406
- [test-url]: https://github.com/stdlib-js/utils-async-for-each/actions/workflows/test.yml?query=branch:v0.2.1
405
+ [test-image]: https://github.com/stdlib-js/utils-async-for-each/actions/workflows/test.yml/badge.svg?branch=v0.2.3
406
+ [test-url]: https://github.com/stdlib-js/utils-async-for-each/actions/workflows/test.yml?query=branch:v0.2.3
407
407
 
408
408
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-async-for-each/main.svg
409
409
  [coverage-url]: https://codecov.io/github/stdlib-js/utils-async-for-each?branch=main
@@ -415,8 +415,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
415
415
 
416
416
  -->
417
417
 
418
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
419
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
418
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
419
+ [chat-url]: https://stdlib.zulipchat.com
420
420
 
421
421
  [stdlib]: https://github.com/stdlib-js/stdlib
422
422
 
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/validate.js", "../lib/limit.js", "../lib/factory.js", "../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'thisArg': {},\n* 'series': false,\n* 'limit': 10\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'thisArg' ) ) {\n\t\topts.thisArg = options.thisArg;\n\t}\n\tif ( hasOwnProp( options, 'series' ) ) {\n\t\topts.series = options.series;\n\t\tif ( !isBoolean( opts.series ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'series', opts.series ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'limit' ) ) {\n\t\topts.limit = options.limit;\n\t\tif ( !isPositiveInteger( opts.limit ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'limit', opts.limit ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// VARIABLES //\n\nvar debug = logger( 'for-each-async:limit' );\n\n\n// MAIN //\n\n/**\n* Invokes a function once for each element in a collection, limiting the number of concurrently pending functions.\n*\n* @private\n* @param {Collection} collection - input collection\n* @param {Options} opts - function options\n* @param {*} [opts.thisArg] - execution context\n* @param {PositiveInteger} [opts.limit] - maximum number of pending function invocations\n* @param {Function} fcn - function to invoke\n* @param {Callback} done - function to invoke upon completion or upon encountering an error\n* @returns {void}\n*/\nfunction limit( collection, opts, fcn, done ) {\n\tvar maxIndex;\n\tvar count;\n\tvar flg;\n\tvar lim;\n\tvar len;\n\tvar idx;\n\tvar i;\n\n\tlen = collection.length;\n\tdebug( 'Collection length: %d', len );\n\n\tif ( len === 0 ) {\n\t\tdebug( 'Finished processing a collection.' );\n\t\treturn done();\n\t}\n\tif ( len < opts.limit ) {\n\t\tlim = len;\n\t} else {\n\t\tlim = opts.limit;\n\t}\n\tdebug( 'Concurrency limit: %d', lim );\n\tdebug( 'Number of arguments: %d', fcn.length );\n\n\tmaxIndex = len - 1;\n\tcount = 0;\n\tidx = -1;\n\tfor ( i = 0; i < lim; i++ ) {\n\t\t// This guard is necessary to protect against synchronous functions which exhaust all collection elements...\n\t\tif ( idx < maxIndex ) {\n\t\t\tnext(); // eslint-disable-line node/callback-return\n\t\t}\n\t}\n\n\t/**\n\t* Callback to invoke a provided function for the next element in a collection.\n\t*\n\t* @private\n\t*/\n\tfunction next() {\n\t\tidx += 1;\n\t\tdebug( 'Collection element %d: %s.', idx, JSON.stringify( collection[ idx ] ) );\n\t\tif ( fcn.length === 2 ) {\n\t\t\tfcn.call( opts.thisArg, collection[ idx ], clbk );\n\t\t} else if ( fcn.length === 3 ) {\n\t\t\tfcn.call( opts.thisArg, collection[ idx ], idx, clbk );\n\t\t} else {\n\t\t\tfcn.call( opts.thisArg, collection[ idx ], idx, collection, clbk );\n\t\t}\n\t}\n\n\t/**\n\t* Callback invoked once a provided function finishes processing a collection element.\n\t*\n\t* @private\n\t* @param {*} [error] - error\n\t* @returns {void}\n\t*/\n\tfunction clbk( error ) {\n\t\tif ( flg ) {\n\t\t\t// Prevent further processing of collection elements:\n\t\t\treturn;\n\t\t}\n\t\tif ( error ) {\n\t\t\tflg = true;\n\t\t\tdebug( 'Encountered an error: %s', error.message );\n\t\t\treturn done( error );\n\t\t}\n\t\tcount += 1;\n\t\tdebug( 'Processed %d of %d collection elements.', count, len );\n\t\tif ( idx < maxIndex ) {\n\t\t\treturn next();\n\t\t}\n\t\tif ( count === len ) {\n\t\t\tdebug( 'Finished processing a collection.' );\n\t\t\treturn done();\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = limit;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\nvar validate = require( './validate.js' );\nvar limit = require( './limit.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function to invoke a function once for each element in a collection.\n*\n* ## Notes\n*\n* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.\n* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).\n*\n* @param {Options} [options] - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series=false] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection\n* @param {Function} fcn - function to invoke for each element in a collection\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} last argument must be a function\n* @returns {Function} function which invokes the provided function once for each element in a collection\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* return next( error );\n* }\n* console.log( 'Successfully read file: %s', file );\n* next();\n* }\n* }\n*\n* var opts = {\n* 'series': true\n* };\n*\n* // Create a `forEachAsync` function which invokes `read` for each collection element sequentially:\n* var forEachAsync = factory( opts, read );\n*\n* // Create a collection over which to iterate:\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* // Define a callback which handles errors:\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Successfully read all files.' );\n* }\n*\n* // Run `read` for each element in `files`:\n* forEachAsync( files, done );\n*/\nfunction factory( options, fcn ) {\n\tvar opts;\n\tvar err;\n\tvar f;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\tf = fcn;\n\t} else {\n\t\tf = options;\n\t}\n\tif ( !isFunction( f ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );\n\t}\n\tif ( opts.series ) {\n\t\topts.limit = 1;\n\t} else if ( !opts.limit ) {\n\t\topts.limit = PINF;\n\t}\n\treturn forEachAsync;\n\n\t/**\n\t* Invokes a function for each element in a collection.\n\t*\n\t* @private\n\t* @param {Collection} collection - input collection\n\t* @param {Callback} done - function to invoke upon completion\n\t* @throws {TypeError} first argument must be a collection\n\t* @throws {TypeError} last argument must be a function\n\t* @returns {void}\n\t*/\n\tfunction forEachAsync( collection, done ) {\n\t\tif ( !isCollection( collection ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );\n\t\t}\n\t\tif ( !isFunction( done ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );\n\t\t}\n\t\treturn limit( collection, opts, f, clbk );\n\n\t\t/**\n\t\t* Callback invoked upon completion.\n\t\t*\n\t\t* @private\n\t\t* @param {*} [error] - error\n\t\t* @returns {void}\n\t\t*/\n\t\tfunction clbk( error ) {\n\t\t\tif ( error ) {\n\t\t\t\treturn done( error );\n\t\t\t}\n\t\t\tdone();\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\n/**\n* Invokes a function once for each element in a collection.\n*\n* ## Notes\n*\n* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.\n* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).\n*\n* @param {Collection} collection - input collection\n* @param {Options} [options] - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series=false] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection\n* @param {Function} fcn - function to invoke for each element in a collection\n* @param {Callback} done - function to invoke upon completion\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} second-to-last argument must be a function\n* @throws {TypeError} last argument must be a function\n* @returns {void}\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Successfully read all files.' );\n* }\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* return next( error );\n* }\n* console.log( 'Successfully read file: %s', file );\n* next();\n* }\n* }\n*\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* forEachAsync( files, read, done );\n*/\nfunction forEachAsync( collection, options, fcn, done ) {\n\tif ( arguments.length < 4 ) {\n\t\treturn factory( options )( collection, fcn );\n\t}\n\tfactory( options, fcn )( collection, done );\n}\n\n\n// EXPORTS //\n\nmodule.exports = forEachAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function once for each element in a collection.\n*\n* @module @stdlib/utils-async-for-each\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n* var forEachAsync = require( '@stdlib/utils-async-for-each' );\n*\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Successfully read all files.' );\n* }\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* error = new Error( 'unable to read file: '+file );\n* return next( error );\n* }\n* console.log( 'Successfully read file: %s', file );\n* next();\n* }\n* }\n*\n* forEachAsync( files, read, done );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,g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,EAC9B,MAAM,IAAI,UAAWX,EAAQ,sEAAuEW,CAAW,CAAE,EAElH,GAAK,CAACb,EAAYc,CAAK,EACtB,MAAM,IAAI,UAAWZ,EAAQ,mEAAoEY,CAAK,CAAE,EAEzG,OAAOT,EAAOQ,EAAYJ,EAAME,EAAGI,CAAK,EASxC,SAASA,EAAMC,EAAQ,CACtB,GAAKA,EACJ,OAAOF,EAAME,CAAM,EAEpBF,EAAK,CACN,CACD,CACD,CAKAf,EAAO,QAAUO,IC3JjB,IAAAW,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,IA2Dd,SAASC,EAAcC,EAAYC,EAASC,EAAKC,EAAO,CACvD,GAAK,UAAU,OAAS,EACvB,OAAOL,EAASG,CAAQ,EAAGD,EAAYE,CAAI,EAE5CJ,EAASG,EAASC,CAAI,EAAGF,EAAYG,CAAK,CAC3C,CAKAN,EAAO,QAAUE,IC7BjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'thisArg': {},\n* 'series': false,\n* 'limit': 10\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'thisArg' ) ) {\n\t\topts.thisArg = options.thisArg;\n\t}\n\tif ( hasOwnProp( options, 'series' ) ) {\n\t\topts.series = options.series;\n\t\tif ( !isBoolean( opts.series ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'series', opts.series ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'limit' ) ) {\n\t\topts.limit = options.limit;\n\t\tif ( !isPositiveInteger( opts.limit ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a positive integer. Option: `%s`.', 'limit', opts.limit ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// VARIABLES //\n\nvar debug = logger( 'for-each-async:limit' );\n\n\n// MAIN //\n\n/**\n* Invokes a function once for each element in a collection, limiting the number of concurrently pending functions.\n*\n* @private\n* @param {Collection} collection - input collection\n* @param {Options} opts - function options\n* @param {*} [opts.thisArg] - execution context\n* @param {PositiveInteger} [opts.limit] - maximum number of pending function invocations\n* @param {Function} fcn - function to invoke\n* @param {Callback} done - function to invoke upon completion or upon encountering an error\n* @returns {void}\n*/\nfunction limit( collection, opts, fcn, done ) {\n\tvar maxIndex;\n\tvar count;\n\tvar flg;\n\tvar lim;\n\tvar len;\n\tvar idx;\n\tvar i;\n\n\tlen = collection.length;\n\tdebug( 'Collection length: %d', len );\n\n\tif ( len === 0 ) {\n\t\tdebug( 'Finished processing a collection.' );\n\t\treturn done();\n\t}\n\tif ( len < opts.limit ) {\n\t\tlim = len;\n\t} else {\n\t\tlim = opts.limit;\n\t}\n\tdebug( 'Concurrency limit: %d', lim );\n\tdebug( 'Number of arguments: %d', fcn.length );\n\n\tmaxIndex = len - 1;\n\tcount = 0;\n\tidx = -1;\n\tfor ( i = 0; i < lim; i++ ) {\n\t\t// This guard is necessary to protect against synchronous functions which exhaust all collection elements...\n\t\tif ( idx < maxIndex ) {\n\t\t\tnext(); // eslint-disable-line node/callback-return\n\t\t}\n\t}\n\n\t/**\n\t* Callback to invoke a provided function for the next element in a collection.\n\t*\n\t* @private\n\t*/\n\tfunction next() {\n\t\tidx += 1;\n\t\tdebug( 'Collection element %d: %s.', idx, JSON.stringify( collection[ idx ] ) );\n\t\tif ( fcn.length === 2 ) {\n\t\t\tfcn.call( opts.thisArg, collection[ idx ], clbk );\n\t\t} else if ( fcn.length === 3 ) {\n\t\t\tfcn.call( opts.thisArg, collection[ idx ], idx, clbk );\n\t\t} else {\n\t\t\tfcn.call( opts.thisArg, collection[ idx ], idx, collection, clbk );\n\t\t}\n\t}\n\n\t/**\n\t* Callback invoked once a provided function finishes processing a collection element.\n\t*\n\t* @private\n\t* @param {*} [error] - error\n\t* @returns {void}\n\t*/\n\tfunction clbk( error ) {\n\t\tif ( flg ) {\n\t\t\t// Prevent further processing of collection elements:\n\t\t\treturn;\n\t\t}\n\t\tif ( error ) {\n\t\t\tflg = true;\n\t\t\tdebug( 'Encountered an error: %s', error.message );\n\t\t\treturn done( error );\n\t\t}\n\t\tcount += 1;\n\t\tdebug( 'Processed %d of %d collection elements.', count, len );\n\t\tif ( idx < maxIndex ) {\n\t\t\treturn next();\n\t\t}\n\t\tif ( count === len ) {\n\t\t\tdebug( 'Finished processing a collection.' );\n\t\t\treturn done();\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = limit;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar format = require( '@stdlib/string-format' );\nvar PINF = require( '@stdlib/constants-float64-pinf' );\nvar validate = require( './validate.js' );\nvar limit = require( './limit.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function to invoke a function once for each element in a collection.\n*\n* ## Notes\n*\n* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.\n* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).\n*\n* @param {Options} [options] - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series=false] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection\n* @param {Function} fcn - function to invoke for each element in a collection\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} last argument must be a function\n* @returns {Function} function which invokes the provided function once for each element in a collection\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* return next( error );\n* }\n* console.log( 'Successfully read file: %s', file );\n* next();\n* }\n* }\n*\n* var opts = {\n* 'series': true\n* };\n*\n* // Create a `forEachAsync` function which invokes `read` for each collection element sequentially:\n* var forEachAsync = factory( opts, read );\n*\n* // Create a collection over which to iterate:\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* // Define a callback which handles errors:\n* function done( error ) {\n* if ( error ) {\n* console.error( error.message );\n* return;\n* }\n* console.log( 'Successfully read all files.' );\n* }\n*\n* // Run `read` for each element in `files`:\n* forEachAsync( files, done );\n*/\nfunction factory( options, fcn ) {\n\tvar opts;\n\tvar err;\n\tvar f;\n\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\tf = fcn;\n\t} else {\n\t\tf = options;\n\t}\n\tif ( !isFunction( f ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', f ) );\n\t}\n\tif ( opts.series ) {\n\t\topts.limit = 1;\n\t} else if ( !opts.limit ) {\n\t\topts.limit = PINF;\n\t}\n\treturn forEachAsync;\n\n\t/**\n\t* Invokes a function for each element in a collection.\n\t*\n\t* @private\n\t* @param {Collection} collection - input collection\n\t* @param {Callback} done - function to invoke upon completion\n\t* @throws {TypeError} first argument must be a collection\n\t* @throws {TypeError} last argument must be a function\n\t* @returns {void}\n\t*/\n\tfunction forEachAsync( collection, done ) {\n\t\tif ( !isCollection( collection ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) );\n\t\t}\n\t\tif ( !isFunction( done ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', done ) );\n\t\t}\n\t\treturn limit( collection, opts, f, clbk );\n\n\t\t/**\n\t\t* Callback invoked upon completion.\n\t\t*\n\t\t* @private\n\t\t* @param {*} [error] - error\n\t\t* @returns {void}\n\t\t*/\n\t\tfunction clbk( error ) {\n\t\t\tif ( error ) {\n\t\t\t\treturn done( error );\n\t\t\t}\n\t\t\tdone();\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\n/**\n* Invokes a function once for each element in a collection.\n*\n* ## Notes\n*\n* - If a provided function calls the provided callback with a truthy error argument, the function suspends execution and immediately calls the `done` callback for subsequent error handling.\n* - This function does **not** guarantee that execution is asynchronous. To do so, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`).\n*\n* @param {Collection} collection - input collection\n* @param {Options} [options] - function options\n* @param {*} [options.thisArg] - execution context\n* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time\n* @param {boolean} [options.series=false] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection\n* @param {Function} fcn - function to invoke for each element in a collection\n* @param {Callback} done - function to invoke upon completion\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} second-to-last argument must be a function\n* @throws {TypeError} last argument must be a function\n* @returns {void}\n*\n* @example\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Successfully processed all files.' );\n* }\n*\n* function process( file, next ) {\n* console.log( 'Processing file: %s', file );\n* setTimeout( onTimeout, 1000 );\n*\n* function onTimeout() {\n* console.log( 'Finished processing file: %s', file );\n* next();\n* }\n* }\n*\n* var files = [\n* 'beep.js',\n* 'boop.js'\n* ];\n*\n* forEachAsync( files, process, done );\n*/\nfunction forEachAsync( collection, options, fcn, done ) {\n\tif ( arguments.length < 4 ) {\n\t\treturn factory( options )( collection, fcn );\n\t}\n\tfactory( options, fcn )( collection, done );\n}\n\n\n// EXPORTS //\n\nmodule.exports = forEachAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function once for each element in a collection.\n*\n* @module @stdlib/utils-async-for-each\n*\n* @example\n* var readFile = require( '@stdlib/fs-read-file' );\n* var forEachAsync = require( '@stdlib/utils-async-for-each' );\n*\n* var files = [\n* './beep.js',\n* './boop.js'\n* ];\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* console.log( 'Successfully read all files.' );\n* }\n*\n* function read( file, next ) {\n* var opts = {\n* 'encoding': 'utf8'\n* };\n* readFile( file, opts, onFile );\n*\n* function onFile( error ) {\n* if ( error ) {\n* error = new Error( 'unable to read file: '+file );\n* return next( error );\n* }\n* console.log( 'Successfully read file: %s', file );\n* next();\n* }\n* }\n*\n* forEachAsync( files, read, done );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA4B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMP,EAAUO,CAAQ,GAGnBN,EAAYM,EAAS,SAAU,IACnCD,EAAK,QAAUC,EAAQ,SAEnBN,EAAYM,EAAS,QAAS,IAClCD,EAAK,OAASC,EAAQ,OACjB,CAACL,EAAWI,EAAK,MAAO,GACrB,IAAI,UAAWF,EAAQ,+DAAgE,SAAUE,EAAK,MAAO,CAAE,EAGnHL,EAAYM,EAAS,OAAQ,IACjCD,EAAK,MAAQC,EAAQ,MAChB,CAACJ,EAAmBG,EAAK,KAAM,GAC5B,IAAI,UAAWF,EAAQ,wEAAyE,QAASE,EAAK,KAAM,CAAE,EAGxH,MAjBC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAkBhH,CAKAR,EAAO,QAAUM,IC/EjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,OAAQ,EAK1BC,EAAQD,EAAQ,sBAAuB,EAiB3C,SAASE,EAAOC,EAAYC,EAAMC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DC,EAAW,IACXC,EAAQ,IAkEZ,SAASC,EAASC,EAASC,EAAM,CAChC,IAAIC,EACAC,EACAC,EAGJ,GADAF,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAC,EAAMN,EAAUK,EAAMF,CAAQ,EACzBG,EACJ,MAAMA,EAEPC,EAAIH,CACL,MACCG,EAAIJ,EAEL,GAAK,CAACP,EAAYW,CAAE,EACnB,MAAM,IAAI,UAAWT,EAAQ,mEAAoES,CAAE,CAAE,EAEtG,OAAKF,EAAK,OACTA,EAAK,MAAQ,EACDA,EAAK,QACjBA,EAAK,MAAQN,GAEPS,EAYP,SAASA,EAAcC,EAAYC,EAAO,CACzC,GAAK,CAACb,EAAcY,CAAW,EAC9B,MAAM,IAAI,UAAWX,EAAQ,sEAAuEW,CAAW,CAAE,EAElH,GAAK,CAACb,EAAYc,CAAK,EACtB,MAAM,IAAI,UAAWZ,EAAQ,mEAAoEY,CAAK,CAAE,EAEzG,OAAOT,EAAOQ,EAAYJ,EAAME,EAAGI,CAAK,EASxC,SAASA,EAAMC,EAAQ,CACtB,GAAKA,EACJ,OAAOF,EAAME,CAAM,EAEpBF,EAAK,CACN,CACD,CACD,CAKAf,EAAO,QAAUO,IC5JjB,IAAAW,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,IAoDd,SAASC,EAAcC,EAAYC,EAASC,EAAKC,EAAO,CACvD,GAAK,UAAU,OAAS,EACvB,OAAOL,EAASG,CAAQ,EAAGD,EAAYE,CAAI,EAE5CJ,EAASG,EAASC,CAAI,EAAGF,EAAYG,CAAK,CAC3C,CAKAN,EAAO,QAAUE,ICtBjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
6
6
  "names": ["require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isPositiveInteger", "format", "validate", "opts", "options", "require_limit", "__commonJSMin", "exports", "module", "logger", "debug", "limit", "collection", "opts", "fcn", "done", "maxIndex", "count", "flg", "lim", "len", "idx", "i", "next", "clbk", "error", "require_factory", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "format", "PINF", "validate", "limit", "factory", "options", "fcn", "opts", "err", "f", "forEachAsync", "collection", "done", "clbk", "error", "require_main", "__commonJSMin", "exports", "module", "factory", "forEachAsync", "collection", "options", "fcn", "done", "setReadOnly", "main", "factory"]
7
7
  }
@@ -258,7 +258,7 @@ interface ForEachAsync {
258
258
  * };
259
259
  *
260
260
  * // Create a `forEachAsync` function which invokes `read` for each collection element sequentially:
261
- * var forEachAsync = factory( opts, read );
261
+ * var forEach = forEachAsync.factory( opts, read );
262
262
  *
263
263
  * // Create a collection over which to iterate:
264
264
  * var files = [
@@ -275,7 +275,7 @@ interface ForEachAsync {
275
275
  * }
276
276
  *
277
277
  * // Run `read` for each element in `files`:
278
- * forEachAsync( files, done );
278
+ * forEach( files, done );
279
279
  */
280
280
  factory<T = unknown, V = unknown>( options: Options<T, V>, fcn: Fcn<T, V> ): FactoryFunction;
281
281
 
@@ -309,7 +309,7 @@ interface ForEachAsync {
309
309
  * }
310
310
  *
311
311
  * // Create a `forEachAsync` function which invokes `read` for each collection element sequentially:
312
- * var forEachAsync = factory( read );
312
+ * var forEach = forEachAsync.factory( read );
313
313
  *
314
314
  * // Create a collection over which to iterate:
315
315
  * var files = [
@@ -326,7 +326,7 @@ interface ForEachAsync {
326
326
  * }
327
327
  *
328
328
  * // Run `read` for each element in `files`:
329
- * forEachAsync( files, done );
329
+ * forEach( files, done );
330
330
  */
331
331
  factory<T = unknown, V = unknown>( fcn: Fcn<T, V> ): FactoryFunction;
332
332
  }
package/lib/factory.js CHANGED
@@ -82,7 +82,8 @@ var limit = require( './limit.js' );
82
82
  * // Define a callback which handles errors:
83
83
  * function done( error ) {
84
84
  * if ( error ) {
85
- * throw error;
85
+ * console.error( error.message );
86
+ * return;
86
87
  * }
87
88
  * console.log( 'Successfully read all files.' );
88
89
  * }
package/lib/main.js CHANGED
@@ -48,36 +48,29 @@ var factory = require( './factory.js' );
48
48
  * @returns {void}
49
49
  *
50
50
  * @example
51
- * var readFile = require( '@stdlib/fs-read-file' );
52
- *
53
51
  * function done( error ) {
54
52
  * if ( error ) {
55
53
  * throw error;
56
54
  * }
57
- * console.log( 'Successfully read all files.' );
55
+ * console.log( 'Successfully processed all files.' );
58
56
  * }
59
57
  *
60
- * function read( file, next ) {
61
- * var opts = {
62
- * 'encoding': 'utf8'
63
- * };
64
- * readFile( file, opts, onFile );
58
+ * function process( file, next ) {
59
+ * console.log( 'Processing file: %s', file );
60
+ * setTimeout( onTimeout, 1000 );
65
61
  *
66
- * function onFile( error ) {
67
- * if ( error ) {
68
- * return next( error );
69
- * }
70
- * console.log( 'Successfully read file: %s', file );
62
+ * function onTimeout() {
63
+ * console.log( 'Finished processing file: %s', file );
71
64
  * next();
72
65
  * }
73
66
  * }
74
67
  *
75
68
  * var files = [
76
- * './beep.js',
77
- * './boop.js'
69
+ * 'beep.js',
70
+ * 'boop.js'
78
71
  * ];
79
72
  *
80
- * forEachAsync( files, read, done );
73
+ * forEachAsync( files, process, done );
81
74
  */
82
75
  function forEachAsync( collection, options, fcn, done ) {
83
76
  if ( arguments.length < 4 ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/utils-async-for-each",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Invoke a function once for each element in a collection.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,16 +30,17 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/assert-has-own-property": "^0.2.1",
34
- "@stdlib/assert-is-boolean": "^0.2.1",
35
- "@stdlib/assert-is-collection": "^0.2.1",
36
- "@stdlib/assert-is-function": "^0.2.1",
37
- "@stdlib/assert-is-plain-object": "^0.2.1",
38
- "@stdlib/assert-is-positive-integer": "^0.2.1",
39
- "@stdlib/constants-float64-pinf": "^0.2.1",
40
- "@stdlib/string-format": "^0.2.1",
41
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1",
42
- "debug": "^2.6.9"
33
+ "@stdlib/assert-has-own-property": "^0.2.3",
34
+ "@stdlib/assert-is-boolean": "^0.2.3",
35
+ "@stdlib/assert-is-collection": "^0.2.3",
36
+ "@stdlib/assert-is-function": "^0.2.3",
37
+ "@stdlib/assert-is-plain-object": "^0.2.3",
38
+ "@stdlib/assert-is-positive-integer": "^0.2.3",
39
+ "@stdlib/constants-float64-pinf": "^0.2.3",
40
+ "@stdlib/string-format": "^0.2.3",
41
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3",
42
+ "debug": "^2.6.9",
43
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.3"
43
44
  },
44
45
  "devDependencies": {},
45
46
  "engines": {