Merge pull request #6728 from chrootsu/lodash-unzip

lodash: signatures of the method _.unzip have been changed
This commit is contained in:
Masahiro Wakame
2015-11-16 22:30:04 +09:00
2 changed files with 73 additions and 17 deletions
+33 -2
View File
@@ -1408,6 +1408,39 @@ 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();
// _.upzip
module TestUnzip {
let array = [['a', 'b'], [1, 2], [true, false]];
let list: _.List<_.List<string|number|boolean>> = {
0: {0: 'a', 1: 'b', length: 2},
1: {0: 1, 1: 2, length: 2},
2: {0: true, 1: false, length: 2},
length: 3
};
{
let result: (string|number|boolean)[][];
result = _.unzip<string|number|boolean>(array);
result = _.unzip<string|number|boolean>(list);
}
{
let result: _.LoDashImplicitArrayWrapper<(string|number|boolean)[]>;
result = _(array).unzip<string|number|boolean>();
result = _(list).unzip<string|number|boolean>();
}
{
let result: _.LoDashExplicitArrayWrapper<(string|number|boolean)[]>;
result = _(array).chain().unzip<string|number|boolean>();
result = _(list).chain().unzip<string|number|boolean>();
}
}
// _.unzipWith
{
let testUnzipWithArray: (number[]|_.List<number>)[];
@@ -1475,9 +1508,7 @@ module TestXor {
}
result = <any[][]>_.zip(['moe', 'larry'], [30, 40], [true, false]);
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();
// _.zipObject
module TestZipObject {
+40 -15
View File
@@ -2721,6 +2721,46 @@ declare module _ {
whereValue: W): LoDashImplicitArrayWrapper<T>;
}
//_.unzip
interface LoDashStatic {
/**
* This method is like _.zip except that it accepts an array of grouped elements and creates an array
* regrouping the elements to their pre-zip configuration.
*
* @param array The array of grouped elements to process.
* @return Returns the new array of regrouped elements.
*/
unzip<T>(array: List<List<T>>): T[][];
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.unzip
*/
unzip<T>(): LoDashImplicitArrayWrapper<T[]>;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.unzip
*/
unzip<T>(): LoDashImplicitArrayWrapper<T[]>;
}
interface LoDashExplicitArrayWrapper<T> {
/**
* @see _.unzip
*/
unzip<T>(): LoDashExplicitArrayWrapper<T[]>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.unzip
*/
unzip<T>(): LoDashExplicitArrayWrapper<T[]>;
}
//_.unzipWith
interface LoDashStatic {
/**
@@ -2829,16 +2869,6 @@ declare module _ {
* @see _.zip
**/
zip(...arrays: any[]): any[];
/**
* @see _.zip
**/
unzip(...arrays: any[][]): any[][];
/**
* @see _.zip
**/
unzip(...arrays: any[]): any[];
}
interface LoDashImplicitArrayWrapper<T> {
@@ -2846,11 +2876,6 @@ declare module _ {
* @see _.zip
**/
zip(...arrays: any[][]): _.LoDashImplicitArrayWrapper<any[][]>;
/**
* @see _.zip
**/
unzip(...arrays: any[]): _.LoDashImplicitArrayWrapper<any[][]>;
}
//_.zipObject