mirror of
https://github.com/lionsoul2014/ip2region.git
synced 2025-12-08 19:25:22 +00:00
1) Add async method: `binarySearch` and `btreeSearch`. 2) Refactor of tests by putting them into `tests` folder. 3) Create several new tests in details. 4) Remove useless and reformat codes to be clear. 5) Remove useless snapshots, because they can be recreated when you run `npm run test`.
23 lines
472 B
JavaScript
23 lines
472 B
JavaScript
/**
|
|
* Async For
|
|
* @param {Array} groupArray
|
|
* @param {Function} exeCallBack
|
|
* @param {Function} finalCallBack
|
|
*/
|
|
function asyncFor(groupArray, exeCallBack, finalCallBack) {
|
|
|
|
let i = 0;
|
|
|
|
function _innerAsyncLoop() {
|
|
if (i < groupArray.length) {
|
|
exeCallBack(groupArray[i++], _innerAsyncLoop);
|
|
}
|
|
else {
|
|
finalCallBack();
|
|
}
|
|
}
|
|
|
|
_innerAsyncLoop();
|
|
}
|
|
|
|
module.exports = asyncFor; |