diff options
Diffstat (limited to 'build/asyncify.js')
-rw-r--r-- | build/asyncify.js | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/build/asyncify.js b/build/asyncify.js deleted file mode 100644 index 6fa1ca0..0000000 --- a/build/asyncify.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = asyncify; - -var _isObject = require('lodash/isObject'); - -var _isObject2 = _interopRequireDefault(_isObject); - -var _rest = require('lodash/rest'); - -var _rest2 = _interopRequireDefault(_rest); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function asyncify(func) { - return (0, _rest2.default)(function (args) { - var callback = args.pop(); - var result; - try { - result = func.apply(this, args); - } catch (e) { - return callback(e); - } - // if result is Promise object - if ((0, _isObject2.default)(result) && typeof result.then === 'function') { - result.then(function (value) { - callback(null, value); - })['catch'](function (err) { - callback(err.message ? err : new Error(err)); - }); - } else { - callback(null, result); - } - }); -} -module.exports = exports['default'];
\ No newline at end of file |