diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 53a316ab50..364bc0ec2b 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -977,6 +977,16 @@ var optionsPartialRight = { defaultsDeep(optionsPartialRight, _.templateSettings); +//_.rearg +var testReargFn = (a: string, b: string, c: string) => [a, b, c]; +interface TestReargResultFn { + (b: string, c: string, a: string): string[]; +} +result = (_.rearg(testReargFn, 2, 0, 1))('b', 'c', 'a'); +result = (_.rearg(testReargFn, [2, 0, 1]))('b', 'c', 'a'); +result = (_(testReargFn).rearg(2, 0, 1).value())('b', 'c', 'a'); +result = (_(testReargFn).rearg([2, 0, 1]).value())('b', 'c', 'a'); + //_.restParam var testRestParamFn = (a: string, b: string, c: number[]) => a + ' ' + b + ' ' + c.join(' '); interface testRestParamFunc { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index ea93f2e70c..225e6bc6c0 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -5654,6 +5654,36 @@ declare module _ { ...args: any[]): Function; } + //_.rearg + interface LoDashStatic { + /** + * Creates a function that invokes func with arguments arranged according to the specified indexes where the + * argument value at the first index is provided as the first argument, the argument value at the second index + * is provided as the second argument, and so on. + * @param func The function to rearrange arguments for. + * @param indexes The arranged argument indexes, specified as individual indexes or arrays of indexes. + * @return Returns the new function. + */ + rearg(func: Function, indexes: number[]): TResult; + + /** + * @see _.rearg + */ + rearg(func: Function, ...indexes: number[]): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.rearg + */ + rearg(indexes: number[]): LoDashObjectWrapper; + + /** + * @see _.rearg + */ + rearg(...indexes: number[]): LoDashObjectWrapper; + } + //_.restParam interface LoDashStatic { /**