diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-13 21:53:45 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-13 21:53:45 +0100 |
commit | 18c96ab6926658d6707f1f3be935078f1cb08411 (patch) | |
tree | 418195a292ce8811679d4c2b1cb7bb0316669d62 /node_modules/async/reflect.js | |
parent | 9657e01be14fa5baa4067da65aff94faf6c973e0 (diff) | |
download | wallet-core-18c96ab6926658d6707f1f3be935078f1cb08411.tar.xz |
node modules
Diffstat (limited to 'node_modules/async/reflect.js')
-rw-r--r-- | node_modules/async/reflect.js | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/node_modules/async/reflect.js b/node_modules/async/reflect.js deleted file mode 100644 index e4fabcc50..000000000 --- a/node_modules/async/reflect.js +++ /dev/null @@ -1,80 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = reflect; - -var _initialParams = require('./internal/initialParams'); - -var _initialParams2 = _interopRequireDefault(_initialParams); - -var _baseRest = require('lodash/_baseRest'); - -var _baseRest2 = _interopRequireDefault(_baseRest); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Wraps the function in another function that always returns data even when it - * errors. - * - * The object returned has either the property `error` or `value`. - * - * @name reflect - * @static - * @memberOf module:Utils - * @method - * @category Util - * @param {Function} fn - The function you want to wrap - * @returns {Function} - A function that always passes null to it's callback as - * the error. The second argument to the callback will be an `object` with - * either an `error` or a `value` property. - * @example - * - * async.parallel([ - * async.reflect(function(callback) { - * // do some stuff ... - * callback(null, 'one'); - * }), - * async.reflect(function(callback) { - * // do some more stuff but error ... - * callback('bad stuff happened'); - * }), - * async.reflect(function(callback) { - * // do some more stuff ... - * callback(null, 'two'); - * }) - * ], - * // optional callback - * function(err, results) { - * // values - * // results[0].value = 'one' - * // results[1].error = 'bad stuff happened' - * // results[2].value = 'two' - * }); - */ -function reflect(fn) { - return (0, _initialParams2.default)(function reflectOn(args, reflectCallback) { - args.push((0, _baseRest2.default)(function callback(err, cbArgs) { - if (err) { - reflectCallback(null, { - error: err - }); - } else { - var value = null; - if (cbArgs.length === 1) { - value = cbArgs[0]; - } else if (cbArgs.length > 1) { - value = cbArgs; - } - reflectCallback(null, { - value: value - }); - } - })); - - return fn.apply(this, args); - }); -} -module.exports = exports['default'];
\ No newline at end of file |