cat-bookmarker/assets/node_modules/enhanced-resolve/lib/forEachBail.js

26 lines
553 B
JavaScript
Raw Normal View History

2024-03-10 18:52:04 +00:00
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
module.exports = function forEachBail(array, iterator, callback) {
if (array.length === 0) return callback();
let i = 0;
const next = () => {
let loop = undefined;
iterator(array[i++], (err, result) => {
if (err || result !== undefined || i >= array.length) {
return callback(err, result);
}
if (loop === false) while (next());
loop = true;
});
if (!loop) loop = false;
return loop;
};
while (next());
};