node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

async-early-error

async-early-error
Build Status

Because I'm tired of typing if(err) return cb(err). Split up your error callbacks:

function statAndRead(file, cb) {
    var handleErr = asyncEarlyError(cb);
 
    fs.stat(file, handleErr(function(stat) {
        fs.readFile(file, handleErr(function(data) {
            cb(null, stat, data);
        });
    });
}

Licence

MIT.