Merge pull request #5888 from chrootsu/lodash-without

lodash: changed _.without() method
This commit is contained in:
Masahiro Wakame
2015-09-20 22:02:47 +09:00
2 changed files with 43 additions and 13 deletions

View File

@@ -497,7 +497,28 @@ result = <{ x: number; }[]>_([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }]).unique('x').v
result = _(testUnzipWithList).unzipWith<number, TResult>(testUnzipWithIterator, any).value();
}
result = <number[]>_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
// _.without
{
let testWithoutArray: number[];
let testWithoutList: _.List<number>;
let result: number[];
result = _.without<number>(testWithoutArray);
result = _.without<number>(testWithoutArray, 1);
result = _.without<number>(testWithoutArray, 1, 2);
result = _.without<number>(testWithoutArray, 1, 2, 3);
result = _.without<number>(testWithoutList);
result = _.without<number>(testWithoutList, 1);
result = _.without<number>(testWithoutList, 1, 2);
result = _.without<number>(testWithoutList, 1, 2, 3);
result = _(testWithoutArray).without().value();
result = _(testWithoutArray).without(1).value();
result = _(testWithoutArray).without(1, 2).value();
result = _(testWithoutArray).without(1, 2, 3).value();
result = _(testWithoutList).without<number>().value();
result = _(testWithoutList).without<number>(1).value();
result = _(testWithoutList).without<number>(1, 2).value();
result = _(testWithoutList).without<number>(1, 2, 3).value();
}
// _.xor
var testXorArray: number[];

33
lodash/lodash.d.ts vendored
View File

@@ -1878,21 +1878,30 @@ declare module _ {
//_.without
interface LoDashStatic {
/**
* Creates an array excluding all provided values using strict equality for comparisons, i.e. ===.
* @param array The array to filter.
* @param values The value(s) to exclude.
* @return A new array of filtered values.
**/
* Creates an array excluding all provided values using SameValueZero for equality comparisons.
*
* @param array The array to filter.
* @param values The values to exclude.
* @return Returns the new array of filtered values.
*/
without<T>(
array: Array<T>,
...values: T[]): T[];
array: T[]|List<T>,
...values: T[]
): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.without
**/
without<T>(
array: List<T>,
...values: T[]): T[];
* @see _.without
*/
without(...values: T[]): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.without
*/
without<TValue>(...values: TValue[]): LoDashArrayWrapper<TValue>;
}
//_.xor