Merge pull request #5847 from chrootsu/lodash-pull

lodash: changed _.pull() method
This commit is contained in:
Masahiro Wakame
2015-09-20 18:51:32 +09:00
2 changed files with 57 additions and 13 deletions
+28 -2
View File
@@ -339,6 +339,34 @@ result = <number>_([1, 2, 3]).last();
result = <number>_.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
result = <number>_.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
// _.pull
{
let testPullArray: TResult[];
let testPullValue: TResult;
let result: TResult[];
result = _.pull<TResult>(testPullArray);
result = _.pull<TResult>(testPullArray, testPullValue);
result = _.pull<TResult>(testPullArray, testPullValue, testPullValue);
result = _.pull<TResult>(testPullArray, testPullValue, testPullValue, testPullValue);
result = _(testPullArray).pull().value();
result = _(testPullArray).pull(testPullValue).value();
result = _(testPullArray).pull(testPullValue, testPullValue).value();
result = _(testPullArray).pull(testPullValue, testPullValue, testPullValue).value();
}
{
let testPullList: _.List<TResult>;
let testPullValue: TResult;
let result: _.List<TResult>;
result = _.pull<TResult>(testPullList);
result = _.pull<TResult>(testPullList, testPullValue);
result = _.pull<TResult>(testPullList, testPullValue, testPullValue);
result = _.pull<TResult>(testPullList, testPullValue, testPullValue, testPullValue);
result = _(testPullList).pull<TResult>().value();
result = _(testPullList).pull<TResult>(testPullValue).value();
result = _(testPullList).pull<TResult>(testPullValue, testPullValue).value();
result = _(testPullList).pull<TResult>(testPullValue, testPullValue, testPullValue).value();
}
// _.pullAt
{
let testPullAtArray: TResult[];
@@ -371,8 +399,6 @@ result = <_.LoDashObjectWrapper<_.Dictionary<any>>>_([['moe', 30], ['larry', 40]
result = <_.Dictionary<any>>_.object([['moe', 30], ['larry', 40]]);
result = <_.LoDashObjectWrapper<_.Dictionary<any>>>_([['moe', 30], ['larry', 40]]).object();
result = <number[]>_.pull([1, 2, 3, 1, 2, 3], 2, 3);
result = <number[]>_.remove([1, 2, 3, 4, 5, 6], function (num: number) { return num % 2 == 0; });
result = <IFoodOrganic[]>_.remove(foodsOrganic, 'organic');
result = <IFoodType[]>_.remove(foodsType, { 'type': 'vegetable' });
+29 -11
View File
@@ -1052,22 +1052,40 @@ declare module _ {
//_.pull
interface LoDashStatic {
/**
* Removes all provided values from the given array using strict equality for comparisons,
* i.e. ===.
* @param array The array to modify.
* @param values The values to remove.
* @return array.
**/
* Removes all provided values from array using SameValueZero for equality comparisons.
*
* Note: Unlike _.without, this method mutates array.
*
* @param array The array to modify.
* @param values The values to remove.
* @return Returns array.
*/
pull<T>(
array: Array<T>,
...values: T[]): T[];
array: T[],
...values: T[]
): T[];
/**
* @see _.pull
**/
* @see _.pull
*/
pull<T>(
array: List<T>,
...values: T[]): T[];
...values: T[]
): List<T>;
}
interface LoDashArrayWrapper<T> {
/**
* @see _.pull
*/
pull(...values: T[]): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.pull
*/
pull<TValue>(...values: TValue[]): LoDashObjectWrapper<List<TValue>>;
}
//_.pullAt