lodash: added _.unzipWith() method

This commit is contained in:
Ilya Mochalov
2015-09-16 03:21:16 +05:00
parent 52b0ea5c97
commit d92927cf93
2 changed files with 59 additions and 2 deletions
+18
View File
@@ -363,6 +363,24 @@ result = <string[]>_(['A', 'b', 'C', 'a', 'B', 'c']).unique(function (letter) {
result = <number[]>_([1, 2.5, 3, 1.5, 2, 3.5]).unique(function (num) { return this.floor(num); }, Math).value();
result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').value();
// _.unzipWith
{
let testUnzipWithArray: (number[]|_.List<number>)[];
let testUnzipWithList: _.List<number[]|_.List<number>>;
let testUnzipWithIterator: {(prev: TResult, curr: number, index?: number, list?: number[]): TResult};
let result: TResult[];
result = _.unzipWith<number, TResult>(testUnzipWithArray);
result = _.unzipWith<number, TResult>(testUnzipWithArray, testUnzipWithIterator);
result = _.unzipWith<number, TResult>(testUnzipWithArray, testUnzipWithIterator, any);
result = _.unzipWith<number, TResult>(testUnzipWithList);
result = _.unzipWith<number, TResult>(testUnzipWithList, testUnzipWithIterator);
result = _.unzipWith<number, TResult>(testUnzipWithList, testUnzipWithIterator, any);
result = _(testUnzipWithArray).unzipWith<number, TResult>(testUnzipWithIterator).value();
result = _(testUnzipWithArray).unzipWith<number, TResult>(testUnzipWithIterator, any).value();
result = _(testUnzipWithList).unzipWith<number, TResult>(testUnzipWithIterator).value();
result = _(testUnzipWithList).unzipWith<number, TResult>(testUnzipWithIterator, any).value();
}
result = <number[]>_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
// _.xor
+41 -2
View File
@@ -1852,6 +1852,45 @@ declare module _ {
whereValue: W): LoDashArrayWrapper<T>;
}
//_.unzipWith
interface LoDashStatic {
/**
* This method is like _.unzip except that it accepts an iteratee to specify how regrouped values should be
* combined. The iteratee is bound to thisArg and invoked with four arguments: (accumulator, value, index,
* group).
*
* @param array The array of grouped elements to process.
* @param iteratee The function to combine regrouped values.
* @param thisArg The this binding of iteratee.
* @return Returns the new array of regrouped elements.
*/
unzipWith<TArray, TResult>(
array: List<List<TArray>>,
iteratee?: MemoIterator<TArray, TResult>,
thisArg?: any
): TResult[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.unzipWith
*/
unzipWith<TArr, TResult>(
iteratee?: MemoIterator<TArr, TResult>,
thisArg?: any
): LoDashArrayWrapper<TResult>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.unzipWith
*/
unzipWith<TArr, TResult>(
iteratee?: MemoIterator<TArr, TResult>,
thisArg?: any
): LoDashArrayWrapper<TResult>;
}
//_.without
interface LoDashStatic {
/**
@@ -8489,10 +8528,10 @@ declare module _ {
}
interface MemoVoidIterator<T, TResult> {
(prev: TResult, curr: T, indexOrKey: any, list?: T[]): void;
(prev: TResult, curr: T, indexOrKey?: any, list?: T[]): void;
}
interface MemoIterator<T, TResult> {
(prev: TResult, curr: T, indexOrKey: any, list?: T[]): TResult;
(prev: TResult, curr: T, indexOrKey?: any, list?: T[]): TResult;
}
/*
interface MemoListIterator<T, TResult> {