From b51c8d74f745550148db523f2468a2e3716b1e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20G=C3=B3rski?= Date: Wed, 6 May 2015 18:32:55 +0200 Subject: [PATCH] _.bind updated to support rest parameters --- lodash/lodash-tests.ts | 14 +++++++++----- lodash/lodash.d.ts | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 10900315f..b16f03b46 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -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', diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index bc629f6ec..dfe67f601 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -4833,7 +4833,7 @@ declare module _ { bind( func: Function, thisArg: any, - ...args: any[]): () => any; + ...args: any[]): (...args: any[]) => any; } interface LoDashObjectWrapper { @@ -4842,7 +4842,7 @@ declare module _ { **/ bind( thisArg: any, - ...args: any[]): LoDashObjectWrapper<() => any>; + ...args: any[]): LoDashObjectWrapper<(...args: any[]) => any>; } //_.bindAll