Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
553 bytes
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | module.exports = function forEachBail(array, iterator, callback) {
|
---|
9 | if (array.length === 0) return callback();
|
---|
10 |
|
---|
11 | let i = 0;
|
---|
12 | const next = () => {
|
---|
13 | let loop = undefined;
|
---|
14 | iterator(array[i++], (err, result) => {
|
---|
15 | if (err || result !== undefined || i >= array.length) {
|
---|
16 | return callback(err, result);
|
---|
17 | }
|
---|
18 | if (loop === false) while (next());
|
---|
19 | loop = true;
|
---|
20 | });
|
---|
21 | if (!loop) loop = false;
|
---|
22 | return loop;
|
---|
23 | };
|
---|
24 | while (next());
|
---|
25 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.