Refactor of codes in node.js

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`.
This commit is contained in:
MaleDong
2018-07-15 11:08:23 +08:00
parent 0a7b2e225f
commit 35fc3cbf23
11 changed files with 644 additions and 161 deletions

View File

@@ -0,0 +1,23 @@
/**
* 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;