From 60ae16ab8e0952b2bc9a55479446624dedb01fc6 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Mon, 23 Jun 2014 16:50:09 +0000 Subject: [PATCH] Add _.xor to Lodash #2377 --- lodash/lodash-tests.ts | 5 +++++ lodash/lodash.d.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index cc4ab4408..1a1f2ef68 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -319,6 +319,11 @@ result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').v result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); +result = _.xor([1, 2, 3, 4, 5], [5, 2, 10]); +result = _.xor([1, 2, 3, 4, 5], [5, 2, 10], [4, 5, 6]); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).xor([5, 2, 10]); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).xor([5, 2, 10], [4, 5, 6]); + result = _.zip(['moe', 'larry'], [30, 40], [true, false]); result = _.unzip(['moe', 'larry'], [30, 40], [true, false]); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 24e55836a..f90397a37 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1968,6 +1968,38 @@ declare module _ { ...values: T[]): T[]; } + //_.xor + interface LoDashStatic { + /** + * Creates an array that is the symmetric difference of the provided arrays. + * @param array The array to process + * @param others The arrays of values to calculate the symmetric difference. + * @return Returns a new array of filtered values. + **/ + xor( + array: Array, + ...others: Array[]): T[]; + /** + * @see _.xor + **/ + xor( + array: List, + ...others: List[]): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.xor + **/ + xor( + ...others: Array[]): LoDashArrayWrapper; + /** + * @see _.xor + **/ + xor( + ...others: List[]): LoDashArrayWrapper; + } + //_.zip interface LoDashStatic { /**