From 1128507d08029cf01fe76610909f2d48a2757d06 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 4 Aug 2015 14:18:43 +0500 Subject: [PATCH] lodash: added _.restParam() method --- lodash/lodash-tests.ts | 12 ++++++++++++ lodash/lodash.d.ts | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 14f68e1c41..16ff862775 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -951,6 +951,18 @@ var optionsPartialRight = { defaultsDeep(optionsPartialRight, _.templateSettings); +//_.restParam +var testRestParamFn = (a: string, b: string, c: number[]) => a + ' ' + b + ' ' + c.join(' '); +interface testRestParamFunc { + (a: string, b: string, c: number[]): string; +} +interface testRestParamResult { + (a: string, b: string, ...c: number[]): string; +} +result = (_.restParam(testRestParamFn, 2))('a', 'b', 1, 2, 3); +result = (_.restParam(testRestParamFn, 2))('a', 'b', 1, 2, 3); +result = (_(testRestParamFn).restParam(2).value())('a', 'b', 1, 2, 3); + var throttled = _.throttle(function () { }, 100); jQuery(window).on('scroll', throttled); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index ee21347665..811c633a73 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5595,6 +5595,30 @@ declare module _ { ...args: any[]): Function; } + //_.restParam + interface LoDashStatic { + /** + * Creates a function that invokes func with the this binding of the created function and arguments from start + * and beyond provided as an array. + * @param func The function to apply a rest parameter to. + * @param start The start position of the rest parameter. + * @return Returns the new function. + */ + restParam(func: Function, start?: number): TResult; + + /** + * @see _.restParam + */ + restParam(func: TFunc, start?: number): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.restParam + */ + restParam(start?: number): LoDashObjectWrapper; + } + //_.throttle interface LoDashStatic { /**