corifeus-utils
Advanced tools
Comparing version 1.1.279-63 to 1.1.285-70
{ | ||
"name": "corifeus-utils", | ||
"version": "1.1.279-63", | ||
"version": "1.1.285-70", | ||
"corifeus": { | ||
@@ -35,3 +35,3 @@ "icon": "fa fa-lightbulb-o", | ||
"devDependencies": { | ||
"corifeus-builder": "^1.7.614-56" | ||
"corifeus-builder": "^1.7.618-59" | ||
}, | ||
@@ -38,0 +38,0 @@ "dependencies": { |
@@ -101,3 +101,3 @@ [//]: #@corifeus-header | ||
--- | ||
[**CORIFEUS-UTILS**](https://pages.corifeus.tk/corifeus-utils) Build v1.1.279-63 | ||
[**CORIFEUS-UTILS**](https://pages.corifeus.tk/corifeus-utils) Build v1.1.285-70 | ||
@@ -104,0 +104,0 @@ [Corifeus](http://www.corifeus.tk) by [Patrik Laszlo](http://patrikx3.tk) |
const forEachAsync = (array, cb, serial = false) => { | ||
const promises = []; | ||
let lastCb; | ||
for(let index = 0; index < array.length; index++) { | ||
const item = array[index]; | ||
const call = () => { | ||
cb(item, index) | ||
} | ||
if (serial) { | ||
if (lastCb === undefined) { | ||
lastCb = cb(item); | ||
lastCb = cb(item, index) | ||
} else { | ||
lastCb = lastCb.then(() => cb(item)); | ||
lastCb = lastCb.then(() => cb(item, index)); | ||
} | ||
} else { | ||
promises.push(cb(item)) | ||
promises.push( cb(item, index)) | ||
} | ||
@@ -15,0 +21,0 @@ } |
@@ -20,8 +20,13 @@ module.exports = { | ||
require: require('./require'), | ||
timer: require('./timer'), | ||
} | ||
const repeat = async (count, callback, serial) => { | ||
return await new Array(count).forEachAsync(callback, serial); | ||
const repeat = (count, callback) => { | ||
return [...Array(count).keys()].forEach(callback); | ||
} | ||
repeat.async = async (count, callback, serial) => { | ||
return await [...Array(count).keys()].forEachAsync(callback, serial); | ||
} | ||
module.exports.repeat = repeat; |
@@ -9,3 +9,3 @@ const resovleDependencies =(options) => { | ||
const { | ||
let { | ||
modules, | ||
@@ -16,2 +16,3 @@ recursive, | ||
recursive = recursive || []; | ||
if (debug) { | ||
@@ -18,0 +19,0 @@ dconsole = console; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22210
25
519