source: imaps-frontend/node_modules/lodash-es/partial.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import baseRest from './_baseRest.js';
2import createWrap from './_createWrap.js';
3import getHolder from './_getHolder.js';
4import replaceHolders from './_replaceHolders.js';
5
6/** Used to compose bitmasks for function metadata. */
7var WRAP_PARTIAL_FLAG = 32;
8
9/**
10 * Creates a function that invokes `func` with `partials` prepended to the
11 * arguments it receives. This method is like `_.bind` except it does **not**
12 * alter the `this` binding.
13 *
14 * The `_.partial.placeholder` value, which defaults to `_` in monolithic
15 * builds, may be used as a placeholder for partially applied arguments.
16 *
17 * **Note:** This method doesn't set the "length" property of partially
18 * applied functions.
19 *
20 * @static
21 * @memberOf _
22 * @since 0.2.0
23 * @category Function
24 * @param {Function} func The function to partially apply arguments to.
25 * @param {...*} [partials] The arguments to be partially applied.
26 * @returns {Function} Returns the new partially applied function.
27 * @example
28 *
29 * function greet(greeting, name) {
30 * return greeting + ' ' + name;
31 * }
32 *
33 * var sayHelloTo = _.partial(greet, 'hello');
34 * sayHelloTo('fred');
35 * // => 'hello fred'
36 *
37 * // Partially applied with placeholders.
38 * var greetFred = _.partial(greet, _, 'fred');
39 * greetFred('hi');
40 * // => 'hi fred'
41 */
42var partial = baseRest(function(func, partials) {
43 var holders = replaceHolders(partials, getHolder(partial));
44 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
45});
46
47// Assign default placeholders.
48partial.placeholder = {};
49
50export default partial;
Note: See TracBrowser for help on using the repository browser.