.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @mrmlnc / readdir-enhanced / lib / sync / for-each.js
1 'use strict';
2
3 module.exports = syncForEach;
4
5 /**
6  * A facade that allows {@link Array.forEach} to be called as though it were asynchronous.
7  *
8  * @param {array} array - The array to iterate over
9  * @param {function} iterator - The function to call for each item in the array
10  * @param {function} done - The function to call when all iterators have completed
11  */
12 function syncForEach (array, iterator, done) {
13   array.forEach(item => {
14     iterator(item, () => {
15       // Note: No error-handling here because this is currently only ever called
16       // by DirectoryReader, which never passes an `error` parameter to the callback.
17       // Instead, DirectoryReader emits an "error" event if an error occurs.
18     });
19   });
20
21   done();
22 }