From 7915426ebcfc80f0253e215a39290b5c61274ac6 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 17 Aug 2015 05:34:58 +0500 Subject: [PATCH] lodash: added _.zipWith() method --- lodash/lodash-tests.ts | 16 ++++++++++++++++ lodash/lodash.d.ts | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 9d87e2a37..fb967df40 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -385,6 +385,22 @@ result = _.unzip(['moe', 'larry'], [30, 40], [true, false]); result = _(['moe', 'larry']).zip([30, 40], [true, false]).value(); result = _(['moe', 'larry']).unzip([30, 40], [true, false]).value(); +// _.zipWith +interface TestZipWithFn { + (a1: number, a2: number): number; +} +var testZipWithFn: TestZipWithFn; +result = _.zipWith([1, 2]); +result = _.zipWith([1, 2], testZipWithFn); +result = _.zipWith([1, 2], testZipWithFn, any); +result = _.zipWith([1, 2], [1, 2], testZipWithFn, any); +result = _.zipWith([1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], testZipWithFn, any); +result = _([1, 2]).zipWith().value(); +result = _([1, 2]).zipWith(testZipWithFn).value(); +result = _([1, 2]).zipWith(testZipWithFn, any).value(); +result = _([1, 2]).zipWith([1, 2], testZipWithFn, any).value(); +result = _([1, 2]).zipWith([1, 2], [1, 2], [1, 2], [1, 2], [1, 2], testZipWithFn, any).value(); + // /* ************* // * Collections * // ************* */ diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b2603ee95..0bd09f2df 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2006,6 +2006,27 @@ declare module _ { object(values?: List): _.LoDashObjectWrapper>; } + //_.zipWith + interface LoDashStatic { + /** + * This method is like _.zip except that it accepts an iteratee to specify how grouped values should be + * combined. The iteratee is bound to thisArg and invoked with four arguments: (accumulator, value, index, + * group). + * @param {...Array} [arrays] The arrays to process. + * @param {Function} [iteratee] The function to combine grouped values. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @return Returns the new array of grouped elements. + */ + zipWith(...args: any[]): TResult[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.zipWith + */ + zipWith(...args: any[]): LoDashArrayWrapper; + } + /* ************* * Collections * ************* */