lodash: changed _.intersection() method

This commit is contained in:
Ilya Mochalov
2015-09-16 01:03:18 +05:00
parent 52b0ea5c97
commit 2f9096fa73
2 changed files with 31 additions and 10 deletions
+12 -1
View File
@@ -290,7 +290,18 @@ result = <number[]>_.initial([1, 2, 3], function (num) {
result = <IFoodOrganic[]>_.initial(foodsOrganic, 'organic');
result = <IFoodType[]>_.initial(foodsType, { 'type': 'vegetable' });
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
@@ -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<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