abc.async(array, action, [callback]);
abc.async.forEach(
[1,2,3],
function (value, callback) {
if (value === 1) {
setTimeout(function () {
callback(value * value);
}, 200)
} else {
callback(value * value);
}
},
function (results) {
results; // [1, 4, 9]
// finish
}
);
abc.async.forEach(
[func1, func2, func3],
function (results) {
// finish
}
);
function func1 (callback) {
// ...
callback();
}
// func2, func3
abc.sequence(array, action, [callback]);
abc.async.sequence(
[1,2,3],
function (value, callback, previousResult) {
value; // 1, 2, 3
previousResult; // null, 1, 4
if (value === 1) {
setTimeout(function () {
callback(value * value);
}, 200)
} else {
callback(value * value);
}
},
function (results) {
results; // [1, 4, 9]
// finish
}
);
abc.async.sequence(
[func1, func2, func3],
function (results) {
// finish
}
);
function func1 (callback, previousResult) {
// ...
callback();
}
// func2, func3
####abc.dir Create dir, if it does not exist.
abc.dir(dirPath, callback)
abc.file.read(filename, callback)
abc.file.write(filename, text, callback)
abc.file.copy(sourceFileName, destinationFileName, callback)
abc.file.binRead(filename, callback)
abc.file.binWrite(filename, data, callback)
abc.file.binCopy(sourceFileName, destinationFileName, callback)
abc.extend(origin, patch1 /*, ..., patchN */, recursive)
Recursive find in dir. Calls fileCallback for each file, and completeCallback at end.
abc.find(dirPath, fileCallback, completeCallback, {recursive: true, excludedDirs: ['node_modules']})
function fileCallback (file, dirPath) {
file; // code.js
dirPath; // src/
return /.*\.js/.test(file); // find all js files
}
Pool of actions limited by action executed in parallel.
var executer = new abc.Executer(30); // No more then 30 actions in parallel.
executer.add(function (callback) {
// do something async
calllback();
});