Comparing version 1.2.2 to 1.3.0
"use strict"; | ||
const setImmediate = require('./setImmediate'); | ||
const values = require('mout/object/values'); | ||
const keys = require('mout/object/keys'); | ||
module.exports = function *(series, n, thunk, ctx) { | ||
var n = Math.min(n || 5, series.length); | ||
var ret = []; | ||
var isArray = Array.isArray(series); | ||
var iterateeSource = isArray ? series: values(series); | ||
var iterateeKeys = keys(series) | ||
var n = Math.min(n || 5, iterateeSource.length); | ||
var ret = isArray ? [] : {}; | ||
var index = 0; | ||
@@ -13,3 +21,3 @@ var cancel = false; | ||
var next = function *() { | ||
if (index >= series.length || cancel) | ||
if (index >= iterateeSource.length || cancel) | ||
return; | ||
@@ -23,3 +31,3 @@ | ||
try { //stop replenishing after error | ||
ret[i] = yield thunk.call(ctx || this, series[i]); | ||
ret[ isArray ? i : iterateeKeys[i] ] = yield thunk.call(ctx || this, iterateeSource[i]); | ||
} catch(err) { | ||
@@ -26,0 +34,0 @@ cancel = true; |
@@ -6,7 +6,8 @@ "use strict"; | ||
module.exports = function *(series, n, thunk, ctx){ | ||
var res = {}; | ||
yield eachLimit(Object.keys(series), n, function* (k){ | ||
yield thunk(series[k], k); | ||
res[k] = yield thunk(series[k], k); | ||
}, ctx); | ||
return Promise.resolve(res); | ||
}; | ||
{ | ||
"name": "async-co", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "Control flow for co with async.js (v2) signatures", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
8952
14
101