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