mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
added _.bindAll definitions
This commit is contained in:
+16
-8
@@ -1,6 +1,6 @@
|
||||
/// <reference path="lodash.d.ts" />
|
||||
|
||||
declare var $;
|
||||
declare var $, jQuery;
|
||||
|
||||
interface IFoodOrganic {
|
||||
name: string;
|
||||
@@ -399,6 +399,14 @@ var func = function (greeting) { return greeting + ' ' + this.name };
|
||||
var func2 = _.bind(func, { 'name': 'moe' }, 'hi');
|
||||
func2();
|
||||
|
||||
var view = {
|
||||
'label': 'docs',
|
||||
'onClick': function() { console.log('clicked ' + this.label); }
|
||||
};
|
||||
|
||||
_.bindAll(view);
|
||||
jQuery('#docs').on('click', view.onClick);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -421,13 +429,13 @@ func2();
|
||||
|
||||
|
||||
|
||||
var buttonView = {
|
||||
label: 'underscore',
|
||||
onClick: function () { alert('clicked: ' + this.label); },
|
||||
onHover: function () { console.log('hovering: ' + this.label); }
|
||||
};
|
||||
_.bindAll(buttonView);
|
||||
$('#underscore_button').bind('click', buttonView.onClick);
|
||||
// var buttonView = {
|
||||
// label: 'underscore',
|
||||
// onClick: function () { alert('clicked: ' + this.label); },
|
||||
// onHover: function () { console.log('hovering: ' + this.label); }
|
||||
// };
|
||||
// _.bindAll(buttonView);
|
||||
// $('#underscore_button').bind('click', buttonView.onClick);
|
||||
|
||||
var fibonacci = _.memoize(function (n) {
|
||||
return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
|
||||
|
||||
Vendored
+75
-76
@@ -1719,88 +1719,87 @@ declare module _ {
|
||||
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
|
||||
* whenever they are invoked. Very handy for binding functions that are going to be used as event handlers,
|
||||
* which would otherwise be invoked with a fairly useless this. If no methodNames are provided, all of the
|
||||
* object's function properties will be bound to it.
|
||||
* @param object The object to bind the methods `methodName` to.
|
||||
* @param methodNames The methods to bind to `object`, optional and if not provided all of `object`'s
|
||||
* methods are bound.
|
||||
* Binds methods of an object to the object itself, overwriting the existing method. Method
|
||||
* names may be specified as individual arguments or as arrays of method names. If no method
|
||||
* names are provided all the function properties of object will be bound.
|
||||
* @param object The object to bind and assign the bound methods to.
|
||||
* @param methodNames The object method names to bind, specified as individual method names
|
||||
* or arrays of method names.
|
||||
**/
|
||||
export function bindAll(
|
||||
object: any,
|
||||
...methodNames: string[]): any;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Partially apply a function by filling in any number of its arguments, without changing its dynamic this value.
|
||||
* A close cousin of bind.
|
||||
|
||||
Reference in New Issue
Block a user