added _.bind definitions

This commit is contained in:
Brian Zengel
2013-10-18 22:17:29 -04:00
parent e57da0eaf2
commit 4383fbe46e
2 changed files with 87 additions and 82 deletions
+10 -5
View File
@@ -393,6 +393,15 @@ _.forEach(saves, function(type) {
asyncSave({ 'type': type, 'complete': done });
});
var func = function (greeting) { return greeting + ' ' + this.name };
// need a second var otherwise typescript thinks func signature is the above func type,
// instead of the newly returned _bind => func type.
var func2 = _.bind(func, { 'name': 'moe' }, 'hi');
func2();
////////////////////////////////////////////////////////////////////////////////////////
@@ -410,11 +419,7 @@ _.forEach(saves, function(type) {
///////////////////////////////////////////////////////////////////////////////////////
var func = function (greeting) { return greeting + ': ' + this.name };
// need a second var otherwise typescript thinks func signature is the above func type,
// instead of the newly returned _bind => func type.
var func2 = _.bind(func, { name: 'moe' }, 'hi');
func2();
var buttonView = {
label: 'underscore',
+77 -77
View File
@@ -1706,87 +1706,87 @@ declare module _ {
n: number,
func: Function): Function;
/**
* Bind a function to an object, meaning that whenever the function is called, the value of this will
* be the object. Optionally, bind arguments to the function to pre-fill them, also known as partial application.
* @param func The function to bind `this` to `object`.
* @param context The `this` pointer whenever `fn` is called.
* @param arguments Additional arguments to pass to `fn` when called.
* @return `fn` with `this` bound to `object`.
* Creates a function that, when called, invokes func with the this binding of thisArg
* and prepends any additional bind arguments to those provided to the bound function.
* @param func The function to bind.
* @param thisArg The this binding of func.
* @param args Arguments to be partially applied.
* @return The new bound function.
**/
export function bind(
func: Function,
context: any,
...arguments: any[]): () => any;
thisArg: any,
...args: any[]): () => any;
/**
* Binds a number of methods on the object, specified by methodNames, to be run in the context of that object