New Upstream Release - node-async-each

Ready changes

Summary

Merged new upstream version: 1.0.6 (was: 1.0.3).

Resulting package

Built on 2023-02-24T22:20 (took 13m11s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases node-async-each

Lintian Result

Diff

diff --git a/.github/funding.yml b/.github/funding.yml
new file mode 100644
index 0000000..43f16ab
--- /dev/null
+++ b/.github/funding.yml
@@ -0,0 +1,2 @@
+github: paulmillr
+# custom: https://paulmillr.com/funding/
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..b4d4dec
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2016 Paul Miller (https://paulmillr.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index 6444d95..6b03be4 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,18 @@
 # async-each
 
-No-bullshit, ultra-simple, 35-lines-of-code async parallel forEach function for JavaScript.
+No-bullshit, ultra-simple, 40-lines-of-code async parallel forEach function for JavaScript.
 
 We don't need junky 30K async libs. Really.
 
 For browsers and node.js.
 
-## Installation
-* Just include async-each before your scripts.
-* `npm install async-each` if you’re using node.js.
-
 ## Usage
 
-* `each(array, iterator, callback);` — `Array`, `Function`, `(optional) Function`
+`npm install async-each` if you're using NPM.
+
+For browsers, just include async-each before your scripts and use global variable `asyncEach`
+
+* `each(array, iterator, callback)` — `Array`, `Function`, `(optional) Function`
 * `iterator(item, next)` receives current item and a callback that will mark the item as done. `next` callback receives optional `error, transformedItem` arguments.
 * `callback(error, transformedArray)` optionally receives first error and transformed result `Array`.
 
@@ -23,30 +23,13 @@ each(['a.js', 'b.js', 'c.js'], fs.readFile, function(error, contents) {
   console.log('Contents for a, b and c:', contents);
 });
 
-// Alternatively in browser:
-asyncEach(list, fn, callback);
+asyncEach(list, fn, callback); // use global var in browser
 ```
 
 ## License
 
 The MIT License (MIT)
 
-Copyright (c) 2016 Paul Miller [(paulmillr.com)](http://paulmillr.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the “Software”), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+Copyright (c) 2016 Paul Miller [(paulmillr.com)](https://paulmillr.com)
+
+See [LICENSE](https://github.com/paulmillr/async-each/blob/master/LICENSE) file.
diff --git a/bower.json b/bower.json
deleted file mode 100644
index 1e95f34..0000000
--- a/bower.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
-  "name": "async-each",
-  "repo": "paulmillr/async-each",
-  "description": "No-bullshit, ultra-simple, 35-lines-of-code async parallel forEach / map function for JavaScript.",
-  "version": "1.0.3",
-  "keywords": [
-    "async", "forEach", "each", "map",
-    "asynchronous",
-    "iteration", "iterate",
-    "loop", "parallel",
-    "concurrent", "array",
-    "flow", "control flow"
-  ],
-  "main": "index.js",
-  "dependencies": {},
-  "development": {},
-  "ignore": [
-    "**/.*",
-    "node_modules",
-    "bower_components"
-  ]
-}
diff --git a/debian/changelog b/debian/changelog
index 9577e65..1491d60 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+node-async-each (1.0.6-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Fri, 24 Feb 2023 22:09:52 -0000
+
 node-async-each (1.0.3-3) unstable; urgency=medium
 
   [ Debian Janitor ]
diff --git a/index.js b/index.js
index 277217d..8806c5f 100644
--- a/index.js
+++ b/index.js
@@ -1,33 +1,34 @@
-// async-each MIT license (by Paul Miller from https://paulmillr.com).
-(function(globals) {
+/*! async-each - MIT License (c) 2016 Paul Miller (paulmillr.com) */
+(function (globals) {
   'use strict';
-  var each = function(items, next, callback) {
+  var each = function (items, next, callback) {
     if (!Array.isArray(items)) throw new TypeError('each() expects array as first argument');
-    if (typeof next !== 'function') throw new TypeError('each() expects function as second argument');
+    if (typeof next !== 'function')
+      throw new TypeError('each() expects function as second argument');
     if (typeof callback !== 'function') callback = Function.prototype; // no-op
 
-    if (items.length === 0) return callback(undefined, items);
-
-    var transformed = new Array(items.length);
-    var count = 0;
+    var total = items.length;
+    if (total === 0) return callback(undefined, items);
+    var transformed = new Array(total);
+    var transformedCount = 0;
     var returned = false;
 
-    items.forEach(function(item, index) {
-      next(item, function(error, transformedItem) {
+    items.forEach(function (item, index) {
+      next(item, function (error, transformedItem) {
         if (returned) return;
         if (error) {
           returned = true;
           return callback(error);
         }
         transformed[index] = transformedItem;
-        count += 1;
-        if (count === items.length) return callback(undefined, transformed);
+        transformedCount += 1; // can't use index: last item could take more time
+        if (transformedCount === total) return callback(undefined, transformed);
       });
     });
   };
 
   if (typeof define !== 'undefined' && define.amd) {
-    define([], function() {
+    define([], function () {
       return each;
     }); // RequireJS
   } else if (typeof module !== 'undefined' && module.exports) {
diff --git a/package.json b/package.json
index 6184f01..691c580 100644
--- a/package.json
+++ b/package.json
@@ -1,20 +1,38 @@
 {
   "name": "async-each",
   "description": "No-bullshit, ultra-simple, 35-lines-of-code async parallel forEach / map function for JavaScript.",
-  "version": "1.0.3",
+  "version": "1.0.6",
   "license": "MIT",
-  "keywords": [
-    "async", "forEach", "each", "map",
-    "asynchronous",
-    "iteration", "iterate",
-    "loop", "parallel",
-    "concurrent", "array",
-    "flow", "control flow"
+  "files": [
+    "index.js"
   ],
-  "files": ["index.js"],
   "homepage": "https://github.com/paulmillr/async-each/",
   "author": "Paul Miller (https://paulmillr.com/)",
-  "repository": "git://github.com/paulmillr/async-each.git",
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/paulmillr/async-each.git"
+  },
   "main": "index.js",
-  "dependencies": {}
+  "dependencies": {},
+  "keywords": [
+    "async",
+    "forEach",
+    "each",
+    "map",
+    "asynchronous",
+    "iteration",
+    "iterate",
+    "loop",
+    "parallel",
+    "concurrent",
+    "array",
+    "flow",
+    "control flow"
+  ],
+  "funding": [
+    {
+      "type": "individual",
+      "url": "https://paulmillr.com/funding/"
+    }
+  ]
 }
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..09dedf0
--- /dev/null
+++ b/test.js
@@ -0,0 +1,16 @@
+var asyncEach = require('.');
+function double(int, callback) {
+  setTimeout(
+    function () {
+      console.log(int, 'done');
+      callback(null, int * 2);
+    },
+    int === 8 ? 1000 : 10
+  );
+}
+var _0to100 = [...Array(10).keys()];
+asyncEach(_0to100, double, function (err, result) {
+  console.log('cb called');
+  if (err) return console.error(err);
+  console.log(result);
+});

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details