From 7d288c874044f11c7f7ad361891acd4edef4ed41 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 5 Aug 2015 17:42:00 +0500 Subject: [PATCH] lodash: added _.spread() method --- lodash/lodash-tests.ts | 8 ++++++++ lodash/lodash.d.ts | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 53a316ab50..7c447fe62e 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -989,6 +989,14 @@ result = (_.restParam(testRestPa result = (_.restParam(testRestParamFn, 2))('a', 'b', 1, 2, 3); result = (_(testRestParamFn).restParam(2).value())('a', 'b', 1, 2, 3); +//_.spread +var testSpreadFn = (who: string, what: string) => who + ' says ' + what; +interface TestSpreadResultFn { + (args: string[]): string; +} +result = (_.spread(testSpreadFn))(['fred', 'hello']); +result = (_(testSpreadFn).spread().value())(['fred', 'hello']); + var throttled = _.throttle(function () { }, 100); jQuery(window).on('scroll', throttled); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index ea93f2e70c..1bf1642a7c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5678,6 +5678,25 @@ declare module _ { restParam(start?: number): LoDashObjectWrapper; } + //_.spread + interface LoDashStatic { + /** + * Creates a function that invokes func with the this binding of the created function and an array of arguments + * much like Function#apply. + * @param func The function to spread arguments over. + * @return Returns the new function. + */ + spread(func: Function): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.spread + */ + spread(): LoDashObjectWrapper; + } + + //_.throttle interface LoDashStatic { /**