Add _.xor to Lodash #2377

This commit is contained in:
Anthony Chu
2014-06-23 16:50:09 +00:00
parent d3f6bcccde
commit 60ae16ab8e
2 changed files with 37 additions and 0 deletions
+5
View File
@@ -319,6 +319,11 @@ result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').v
result = <number[]>_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
result = <number[]>_.xor([1, 2, 3, 4, 5], [5, 2, 10]);
result = <number[]>_.xor([1, 2, 3, 4, 5], [5, 2, 10], [4, 5, 6]);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4, 5]).xor([5, 2, 10]);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4, 5]).xor([5, 2, 10], [4, 5, 6]);
result = <any[][]>_.zip(['moe', 'larry'], [30, 40], [true, false]);
result = <any[][]>_.unzip(['moe', 'larry'], [30, 40], [true, false]);
+32
View File
@@ -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<T>(
array: Array<T>,
...others: Array<T>[]): T[];
/**
* @see _.xor
**/
xor<T>(
array: List<T>,
...others: List<T>[]): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.xor
**/
xor(
...others: Array<T>[]): LoDashArrayWrapper<T>;
/**
* @see _.xor
**/
xor(
...others: List<T>[]): LoDashArrayWrapper<T>;
}
//_.zip
interface LoDashStatic {
/**