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.
27 lines
654 B
27 lines
654 B
2 years ago
|
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;
|