You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					26 lines
				
				1012 B
			
		
		
			
		
	
	
					26 lines
				
				1012 B
			| 
								 
											3 years ago
										 
									 | 
							
								define(['./restArguments', './_executeBound', './underscore'], function (restArguments, _executeBound, underscore) {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  // Partially apply a function by creating a version that has had some of its
							 | 
						||
| 
								 | 
							
								  // arguments pre-filled, without changing its dynamic `this` context. `_` acts
							 | 
						||
| 
								 | 
							
								  // as a placeholder by default, allowing any combination of arguments to be
							 | 
						||
| 
								 | 
							
								  // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument.
							 | 
						||
| 
								 | 
							
								  var partial = restArguments(function(func, boundArgs) {
							 | 
						||
| 
								 | 
							
								    var placeholder = partial.placeholder;
							 | 
						||
| 
								 | 
							
								    var bound = function() {
							 | 
						||
| 
								 | 
							
								      var position = 0, length = boundArgs.length;
							 | 
						||
| 
								 | 
							
								      var args = Array(length);
							 | 
						||
| 
								 | 
							
								      for (var i = 0; i < length; i++) {
							 | 
						||
| 
								 | 
							
								        args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i];
							 | 
						||
| 
								 | 
							
								      }
							 | 
						||
| 
								 | 
							
								      while (position < arguments.length) args.push(arguments[position++]);
							 | 
						||
| 
								 | 
							
								      return _executeBound(func, bound, this, this, args);
							 | 
						||
| 
								 | 
							
								    };
							 | 
						||
| 
								 | 
							
								    return bound;
							 | 
						||
| 
								 | 
							
								  });
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  partial.placeholder = underscore;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								  return partial;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								});
							 |