From 843e046e8a33650a706032640847c964de5855d1 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 8 Oct 2015 07:19:25 +0500 Subject: [PATCH] lodash: changed signatures of the method _.union --- lodash/lodash-tests.ts | 29 +++++++++++++++++++++++++++-- lodash/lodash.d.ts | 34 +++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index db15ebc4a..ff18106b0 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -710,9 +710,34 @@ module TestTakeWhile { result = _(list).takeWhile<{a: number;}, TResult>({a: 42}).value(); } -result = _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); +// _.union +module TestUnion { + let array: TResult[]; + let list: _.List; + let result: TResult[]; -result = _([1, 2, 3]).union([101, 2, 1, 10], [2, 1]).value(); + result = _.union(); + + result = _.union(array); + result = _.union(array, list); + result = _.union(array, list, array); + + result = _.union(list); + result = _.union(list, array); + result = _.union(list, array, list); + + result = _(array).union().value(); + result = _(array).union(list).value(); + result = _(array).union(list, array).value(); + + result = _(array).union().value(); + result = _(array).union(list).value(); + result = _(array).union(list, array).value(); + + result = _(list).union().value(); + result = _(list).union(array).value(); + result = _(list).union(array, list).value(); +} result = _.uniq([1, 2, 1, 3, 1]); result = _.uniq([1, 1, 2, 2, 3], true); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 5a3e0df9e..ca36002d5 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1662,24 +1662,32 @@ declare module _ { //_.union interface LoDashStatic { /** - * Creates an array of unique values, in order, of the provided arrays using strict - * equality for comparisons, i.e. ===. - * @param arrays The arrays to inspect. - * @return Returns an array of composite values. - **/ - union(...arrays: Array[]): T[]; - - /** - * @see _.union - **/ + * Creates an array of unique values, in order, from all of the provided arrays using SameValueZero for + * equality comparisons. + * + * @param arrays The arrays to inspect. + * @return Returns the new array of combined values. + */ union(...arrays: List[]): T[]; } interface LoDashArrayWrapper { /** - * @see _.union - **/ - union(...arrays: (Array|List)[]): LoDashArrayWrapper; + * @see _.union + */ + union(...arrays: List[]): LoDashArrayWrapper; + + /** + * @see _.union + */ + union(...arrays: List[]): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.union + */ + union(...arrays: List[]): LoDashArrayWrapper; } //_.uniq