source: trip-planner-front/node_modules/async/apply.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7exports.default = function (fn /*, ...args*/) {
8 var args = (0, _slice2.default)(arguments, 1);
9 return function () /*callArgs*/{
10 var callArgs = (0, _slice2.default)(arguments);
11 return fn.apply(null, args.concat(callArgs));
12 };
13};
14
15var _slice = require('./internal/slice');
16
17var _slice2 = _interopRequireDefault(_slice);
18
19function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
21;
22
23/**
24 * Creates a continuation function with some arguments already applied.
25 *
26 * Useful as a shorthand when combined with other control flow functions. Any
27 * arguments passed to the returned function are added to the arguments
28 * originally passed to apply.
29 *
30 * @name apply
31 * @static
32 * @memberOf module:Utils
33 * @method
34 * @category Util
35 * @param {Function} fn - The function you want to eventually apply all
36 * arguments to. Invokes with (arguments...).
37 * @param {...*} arguments... - Any number of arguments to automatically apply
38 * when the continuation is called.
39 * @returns {Function} the partially-applied function
40 * @example
41 *
42 * // using apply
43 * async.parallel([
44 * async.apply(fs.writeFile, 'testfile1', 'test1'),
45 * async.apply(fs.writeFile, 'testfile2', 'test2')
46 * ]);
47 *
48 *
49 * // the same process without using apply
50 * async.parallel([
51 * function(callback) {
52 * fs.writeFile('testfile1', 'test1', callback);
53 * },
54 * function(callback) {
55 * fs.writeFile('testfile2', 'test2', callback);
56 * }
57 * ]);
58 *
59 * // It's possible to pass any number of additional arguments when calling the
60 * // continuation:
61 *
62 * node> var fn = async.apply(sys.puts, 'one');
63 * node> fn('two', 'three');
64 * one
65 * two
66 * three
67 */
68module.exports = exports['default'];
Note: See TracBrowser for help on using the repository browser.