From 54f849120e20d65738dafdb7deb6aed367cca713 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 12 Nov 2015 13:39:47 +0500 Subject: [PATCH] lodash: signatures of the method _.unzip have been changed --- lodash/lodash-tests.ts | 35 +++++++++++++++++++++++++-- lodash/lodash.d.ts | 55 ++++++++++++++++++++++++++++++------------ 2 files changed, 73 insertions(+), 17 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4c587b57b..7ac8f0bb2 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1408,6 +1408,39 @@ result = _(['A', 'b', 'C', 'a', 'B', 'c']).unique(function (letter) { result = _([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> = { + 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(array); + result = _.unzip(list); + } + + { + let result: _.LoDashImplicitArrayWrapper<(string|number|boolean)[]>; + + result = _(array).unzip(); + result = _(list).unzip(); + } + + { + let result: _.LoDashExplicitArrayWrapper<(string|number|boolean)[]>; + + result = _(array).chain().unzip(); + result = _(list).chain().unzip(); + } +} + // _.unzipWith { let testUnzipWithArray: (number[]|_.List)[]; @@ -1475,9 +1508,7 @@ module TestXor { } result = _.zip(['moe', 'larry'], [30, 40], [true, false]); -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(); // _.zipObject module TestZipObject { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 98d8bf55d..96c6b629d 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2721,6 +2721,46 @@ declare module _ { whereValue: W): LoDashImplicitArrayWrapper; } + //_.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(array: List>): T[][]; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.unzip + */ + unzip(): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.unzip + */ + unzip(): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.unzip + */ + unzip(): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.unzip + */ + unzip(): LoDashExplicitArrayWrapper; + } + //_.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 { @@ -2846,11 +2876,6 @@ declare module _ { * @see _.zip **/ zip(...arrays: any[][]): _.LoDashImplicitArrayWrapper; - - /** - * @see _.zip - **/ - unzip(...arrays: any[]): _.LoDashImplicitArrayWrapper; } //_.zipObject