wallet-core/node_modules/async/constant.js

66 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-05-03 15:35:00 +02:00
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
2017-05-24 15:10:37 +02:00
exports.default = function () /*...values*/{
var values = (0, _slice2.default)(arguments);
var args = [null].concat(values);
return function () /*...ignoredArgs, callback*/{
var callback = arguments[arguments.length - 1];
return callback.apply(this, args);
};
};
2017-05-03 15:35:00 +02:00
2017-05-24 15:10:37 +02:00
var _slice = require('./internal/slice');
2017-05-03 15:35:00 +02:00
2017-05-24 15:10:37 +02:00
var _slice2 = _interopRequireDefault(_slice);
2017-05-03 15:35:00 +02:00
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2017-05-24 15:10:37 +02:00
;
2017-05-03 15:35:00 +02:00
/**
* Returns a function that when called, calls-back with the values provided.
* Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
* [`auto`]{@link module:ControlFlow.auto}.
*
* @name constant
* @static
* @memberOf module:Utils
* @method
* @category Util
* @param {...*} arguments... - Any number of arguments to automatically invoke
* callback with.
* @returns {AsyncFunction} Returns a function that when invoked, automatically
* invokes the callback with the previous given arguments.
* @example
*
* async.waterfall([
* async.constant(42),
* function (value, next) {
* // value === 42
* },
* //...
* ], callback);
*
* async.waterfall([
* async.constant(filename, "utf8"),
* fs.readFile,
* function (fileData, next) {
* //...
* }
* //...
* ], callback);
*
* async.auto({
* hostname: async.constant("https://server.net/"),
* port: findFreePort,
* launchServer: ["hostname", "port", function (options, cb) {
* startServer(options, cb);
* }],
* //...
* }, callback);
*/
module.exports = exports['default'];