Merge pull request #6204 from chrootsu/lodash-union

lodash: changed signatures of the method _.union
This commit is contained in:
Masahiro Wakame
2015-10-13 00:23:59 +09:00
2 changed files with 48 additions and 15 deletions
+27 -2
View File
@@ -758,9 +758,34 @@ module TestTakeWhile {
result = _(list).takeWhile<{a: number;}, TResult>({a: 42}).value();
}
result = <number[]>_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
// _.union
module TestUnion {
let array: TResult[];
let list: _.List<TResult>;
let result: TResult[];
result = <number[]>_([1, 2, 3]).union([101, 2, 1, 10], [2, 1]).value();
result = _.union<TResult>();
result = _.union<TResult>(array);
result = _.union<TResult>(array, list);
result = _.union<TResult>(array, list, array);
result = _.union<TResult>(list);
result = _.union<TResult>(list, array);
result = _.union<TResult>(list, array, list);
result = _(array).union().value();
result = _(array).union(list).value();
result = _(array).union(list, array).value();
result = _(array).union<TResult>().value();
result = _(array).union<TResult>(list).value();
result = _(array).union<TResult>(list, array).value();
result = _(list).union<TResult>().value();
result = _(list).union<TResult>(array).value();
result = _(list).union<TResult>(array, list).value();
}
result = <number[]>_.uniq([1, 2, 1, 3, 1]);
result = <number[]>_.uniq([1, 1, 2, 2, 3], true);
+21 -13
View File
@@ -1651,24 +1651,32 @@ declare module _ {
//_.union
interface LoDashStatic {
/**
* Creates an array of unique values, in order, of the provided arrays using strict
* equality for comparisons, i.e. ===.
* @param arrays The arrays to inspect.
* @return Returns an array of composite values.
**/
union<T>(...arrays: Array<T>[]): T[];
/**
* @see _.union
**/
* Creates an array of unique values, in order, from all of the provided arrays using SameValueZero for
* equality comparisons.
*
* @param arrays The arrays to inspect.
* @return Returns the new array of combined values.
*/
union<T>(...arrays: List<T>[]): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.union
**/
union<T>(...arrays: (Array<T>|List<T>)[]): LoDashArrayWrapper<T>;
* @see _.union
*/
union(...arrays: List<T>[]): LoDashArrayWrapper<T>;
/**
* @see _.union
*/
union<T>(...arrays: List<T>[]): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.union
*/
union<T>(...arrays: List<T>[]): LoDashArrayWrapper<T>;
}
//_.uniq