Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
134 lines (125 sloc) 2.62 KB

abc

abc.async.forEach

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.async.sequence

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

abc.file.read(filename, callback)

abc.file.write

abc.file.write(filename, text, callback)

abc.file.copy

abc.file.copy(sourceFileName, destinationFileName, callback)

abc.file.binRead

abc.file.binRead(filename, callback)

abc.file.binWrite

abc.file.binWrite(filename, data, callback)

abc.file.binCopy

abc.file.binCopy(sourceFileName, destinationFileName, callback)

abc.extend

abc.extend(origin, patch1 /*, ..., patchN */, recursive)

abc.find

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
}

abc.Executer

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();
});