You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
654 B
26 lines
654 B
var isFn = require('./isFn');
|
|
var restArgs = require('./restArgs');
|
|
exports = function(fn) {
|
|
if (isFn(fn)) {
|
|
return restArgs(function(args) {
|
|
return fn
|
|
.apply(this, args)
|
|
.then(function(v) {
|
|
return [v, null];
|
|
})
|
|
.catch(function(err) {
|
|
return [void 0, err];
|
|
});
|
|
});
|
|
} else {
|
|
return fn
|
|
.then(function(v) {
|
|
return [v, null];
|
|
})
|
|
.catch(function(err) {
|
|
return [void 0, err];
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = exports;
|
|
|