10 examples of 'lodash loop through array' in JavaScript

Every line of 'lodash loop through array' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
159async function loopAsync(arr, callback) {
160 for (let i = 0; i < arr.length; i++) {
161 arr[i] = await callback(arr[i]);
162 }
163 return await Promise.all(arr);
164}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

7function parallel(array, fn) {
8
9 var length = array.length;
10 var results = new Array(length);
11 var loaded = 0;
12
13 function wrap(fn, index) {
14 fn(function callback(err) {
15 results[index] = arguments;
16 loaded++;
17 ready();
18 });
19 }
20
21 function ready() {
22 if (loaded >= length) {
23 fn.apply(null, results);
24 }
25 }
26
27 ready();
28
29 fold(array, 0, wrap);
30
31}
77function iterate(index, array, result) {
78 if (index >= array.length) {
79 return result;
80 } else return callback(array[index], index).then(function (res) {
81 result.push(res);
82 return iterate(index + 1, array, result);
83 });
84}
1export default function forArray(arr, iteratee) {
2 for (var i = 0; i < arr.length; i++) {
3 if (iteratee(arr[i], i, arr) === false) break;
4 }
5 return arr;
6}
22function completeLoopAction(array, value, action, arrayProp){
23 for (var j = 0; j < array.length; j++) {
24 if(arrayProp){
25 if (array[j][arrayProp] == value) {
26 break;
27 }
28 } else {
29 if (array[j] == value) {
30 break;
31 }
32 }
33 }
34 if (j == array.length) {
35 action();
36 }
37}
6function parallel (arr, cb) {
7 var results = []
8 , complete = 0
9 ;
10 for (var i=0;i<arr.length;i++) {
11 ;(function (i) {
12 arr[i][0](function () {
13 results[i] = Array.prototype.slice.call(arguments)
14 complete += 1
15 if (complete === arr.length) {
16 for (var ii=0;ii<arr.length;ii++) {
17 arr[ii][1].apply(arr[ii][1], results[ii])
18 }
19 cb()
20 }
21 })
22 })(i)
23 }
24 if (arr.length === 0) cb()
25}
117var _loop3 = function _loop3(_j) {
118 match = childTests.every(function (tt) {
119 return test(children, _j, tt).match;
120 });
121
122 if (match) {
123 res.j = _j; // all tests true, continue with next key of pattern t
124
125 return "break";
126 }
127};
95exports.loop = function loop(fn, start, end, by) {
96 by = by || 1;
97 for (var i = start; i <= end; i += by) fn(i);
98};
389function forEach (array, callback, thisObj)
390 {
391 for (var i=0; i<array.length; i++)
392 {
393 if (array.hasOwnProperty(i))
394 {
395 callback.call(thisObj, array[i], i, array);
396 }
397 }
398}
422function __loop__(iter, fn)
423{
424 var nodeCount = 0;
425 for (var i = 0; i < iter.length; ++i)
426 {
427 iter[i][0] = i;
428 iter[i][1] = nodeCount;
429 nodeCount += fn.apply(this, iter[i]);
430 //if (FBTrace.DBG_DOM) FBTrace.sysout("nodeCount", nodeCount);
431 }
432 return nodeCount;
433}

Related snippets