This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function mapLimit (col, limit, mapFunc, doneFunc, newCol = [], index = { value: 0 }, freeThreads = { value: limit }) { | |
| if (freeThreads.value > 0 && index.value < col.length) { | |
| // Save current index | |
| const curIndex = index.value | |
| // Now the number of free threads is lower on 1 | |
| freeThreads.value -= 1 | |
| mapFunc((err, newItem) => { | |
| if (err) { | |
| // Smth bad happend, we call doneFunc with err |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const assert = require('assert') | |
| function flattenArray (nestedArray, resArray = []) { | |
| for (let i = 0; i < nestedArray.length; i++) { | |
| if (Array.isArray(nestedArray[i])) { | |
| flattenArray(nestedArray[i], resArray) | |
| } else { | |
| resArray.push(nestedArray[i]) | |
| } | |
| } |
NewerOlder