From 2f9096fa7309f985fee2f1b2faf278281a05281c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 15 Sep 2015 02:33:09 +0500 Subject: [PATCH] lodash: changed _.intersection() method --- lodash/lodash-tests.ts | 13 ++++++++++++- lodash/lodash.d.ts | 28 +++++++++++++++++++--------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244..049e7c4f1 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -290,7 +290,18 @@ result = _.initial([1, 2, 3], function (num) { result = _.initial(foodsOrganic, 'organic'); result = _.initial(foodsType, { 'type': 'vegetable' }); -result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); +// _.intersection +{ + let testIntersectionArray: TResult[]; + let testIntersectionList: _.List; + let result: TResult[]; + result = _.intersection(testIntersectionArray, testIntersectionList); + result = _.intersection(testIntersectionList, testIntersectionArray, testIntersectionList); + result = _(testIntersectionArray).intersection(testIntersectionArray).value(); + result = _(testIntersectionArray).intersection(testIntersectionList, testIntersectionArray).value(); + result = _(testIntersectionList).intersection(testIntersectionArray).value(); + result = _(testIntersectionList).intersection(testIntersectionList, testIntersectionArray).value(); +} result = _.last([1, 2, 3]); result = _([1, 2, 3]).last(); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710b..bb8c325ec 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1028,17 +1028,27 @@ declare module _ { //_.intersection interface LoDashStatic { /** - * Creates an array of unique values present in all provided arrays using strict - * equality for comparisons, i.e. ===. - * @param arrays The arrays to inspect. - * @return Returns an array of composite values. - **/ - intersection(...arrays: Array[]): T[]; + * Creates an array of unique values that are included in all of the provided arrays using SameValueZero for + * equality comparisons. + * + * @param arrays The arrays to inspect. + * @return Returns the new array of shared values. + */ + intersection(...arrays: (T[]|List)[]): T[]; + } + interface LoDashArrayWrapper { /** - * @see _.intersection - **/ - intersection(...arrays: List[]): T[]; + * @see _.intersection + */ + intersection(...arrays: (TResult[]|List)[]): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.intersection + */ + intersection(...arrays: (TResult[]|List)[]): LoDashArrayWrapper; } //_.last