Merge pull request #5824 from chrootsu/lodash-intersection

lodash: changed _.intersection() method
This commit is contained in:
Masahiro Wakame
2015-09-20 14:31:50 +09:00
2 changed files with 31 additions and 10 deletions
+12 -1
View File
@@ -302,7 +302,18 @@ result = <number>_.indexOf([1, 1, 2, 2, 3, 3], 2, true);
result = _(testInitalList).initial<TResult>().value();
}
result = <number[]>_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
// _.intersection
{
let testIntersectionArray: TResult[];
let testIntersectionList: _.List<TResult>;
let result: TResult[];
result = _.intersection<TResult>(testIntersectionArray, testIntersectionList);
result = _.intersection<TResult>(testIntersectionList, testIntersectionArray, testIntersectionList);
result = _(testIntersectionArray).intersection<TResult>(testIntersectionArray).value();
result = _(testIntersectionArray).intersection<TResult>(testIntersectionList, testIntersectionArray).value();
result = _(testIntersectionList).intersection<TResult>(testIntersectionArray).value();
result = _(testIntersectionList).intersection<TResult>(testIntersectionList, testIntersectionArray).value();
}
result = <number>_.last([1, 2, 3]);
result = <number>_([1, 2, 3]).last();
+19 -9
View File
@@ -988,17 +988,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<T>(...arrays: Array<T>[]): 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<T>(...arrays: (T[]|List<T>)[]): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.intersection
**/
intersection<T>(...arrays: List<T>[]): T[];
* @see _.intersection
*/
intersection<TResult>(...arrays: (TResult[]|List<TResult>)[]): LoDashArrayWrapper<TResult>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.intersection
*/
intersection<TResult>(...arrays: (TResult[]|List<TResult>)[]): LoDashArrayWrapper<TResult>;
}
//_.last