mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 21:40:21 +00:00
added _.bind definitions
This commit is contained in:
+10
-5
@@ -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',
|
||||
|
||||
Vendored
+77
-77
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user