lodash: added _.zipWith() method

This commit is contained in:
Ilya Mochalov
2015-08-17 05:34:58 +05:00
parent 5109e1269d
commit 7915426ebc
2 changed files with 37 additions and 0 deletions
+16
View File
@@ -385,6 +385,22 @@ result = <any[][]>_.unzip(['moe', 'larry'], [30, 40], [true, false]);
result = <any[][]>_(['moe', 'larry']).zip([30, 40], [true, false]).value();
result = <any[][]>_(['moe', 'larry']).unzip([30, 40], [true, false]).value();
// _.zipWith
interface TestZipWithFn {
(a1: number, a2: number): number;
}
var testZipWithFn: TestZipWithFn;
result = <number[]>_.zipWith<number>([1, 2]);
result = <number[]>_.zipWith<number>([1, 2], testZipWithFn);
result = <number[]>_.zipWith<number>([1, 2], testZipWithFn, any);
result = <number[]>_.zipWith<number>([1, 2], [1, 2], testZipWithFn, any);
result = <number[]>_.zipWith<number>([1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], testZipWithFn, any);
result = <number[]>_([1, 2]).zipWith<number>().value();
result = <number[]>_([1, 2]).zipWith<number>(testZipWithFn).value();
result = <number[]>_([1, 2]).zipWith<number>(testZipWithFn, any).value();
result = <number[]>_([1, 2]).zipWith<number>([1, 2], testZipWithFn, any).value();
result = <number[]>_([1, 2]).zipWith<number>([1, 2], [1, 2], [1, 2], [1, 2], [1, 2], testZipWithFn, any).value();
// /* *************
// * Collections *
// ************* */
+21
View File
@@ -2006,6 +2006,27 @@ declare module _ {
object(values?: List<any>): _.LoDashObjectWrapper<Dictionary<any>>;
}
//_.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<TResult>(...args: any[]): TResult[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.zipWith
*/
zipWith<TResult>(...args: any[]): LoDashArrayWrapper<TResult>;
}
/* *************
* Collections *
************* */