Merge pull request #4276 from arturgorski/master

_.bind updated to support rest parameters
This commit is contained in:
Masahiro Wakame
2015-05-08 20:49:21 +09:00
2 changed files with 11 additions and 7 deletions
+9 -5
View File
@@ -634,12 +634,16 @@ _.forEach(saves, function (type) {
asyncSave({ 'type': type, 'complete': done });
});
var funcBind = function (greeting: string) { return greeting + ' ' + this.name };
var funcBind2: () => any = _.bind(funcBind, { 'name': 'moe' }, 'hi');
funcBind2();
var funcBind = function(greeting: string, punctuation: string) { return greeting + ' ' + this.user + punctuation; };
var funcBound1: (punctuation: string) => any = _.bind(funcBind, { 'name': 'moe' }, 'hi');
funcBound1('!');
var funcBind3: () => any = _(funcBind).bind({ 'name': 'moe' }, 'hi').value();
funcBind3();
var funcBound2: (punctuation: string) => any = _(funcBind).bind({ 'name': 'moe' }, 'hi').value();
funcBound2('!');
var addTwoNumbers = function (x: number, y: number) { return x + y };
var plusTwo = _.bind(addTwoNumbers, null, 2);
plusTwo(100);
var view = {
'label': 'docs',
+2 -2
View File
@@ -4833,7 +4833,7 @@ declare module _ {
bind(
func: Function,
thisArg: any,
...args: any[]): () => any;
...args: any[]): (...args: any[]) => any;
}
interface LoDashObjectWrapper<T> {
@@ -4842,7 +4842,7 @@ declare module _ {
**/
bind(
thisArg: any,
...args: any[]): LoDashObjectWrapper<() => any>;
...args: any[]): LoDashObjectWrapper<(...args: any[]) => any>;
}
//_.bindAll