source: frontend/node_modules/underscore/cjs/partial.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1009 bytes
Line 
1var restArguments = require('./restArguments.js');
2var _executeBound = require('./_executeBound.js');
3var underscore = require('./underscore.js');
4
5// Partially apply a function by creating a version that has had some of its
6// arguments pre-filled, without changing its dynamic `this` context. `_` acts
7// as a placeholder by default, allowing any combination of arguments to be
8// pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.
9var partial = restArguments(function(func, boundArgs) {
10 var placeholder = partial.placeholder;
11 var bound = function() {
12 var position = 0, length = boundArgs.length;
13 var args = Array(length);
14 for (var i = 0; i < length; i++) {
15 args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];
16 }
17 while (position < arguments.length) args.push(arguments[position++]);
18 return _executeBound(func, bound, this, this, args);
19 };
20 return bound;
21});
22
23partial.placeholder = underscore;
24
25module.exports = partial;
Note: See TracBrowser for help on using the repository browser.