diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index aa790ce4c..b5880412f 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -501,10 +501,41 @@ result = <_.LoDashObjectWrapper<_.Dictionary>>_([['moe', 30], ['larry', 40] result = <_.Dictionary>_.object([['moe', 30], ['larry', 40]]); result = <_.LoDashObjectWrapper<_.Dictionary>>_([['moe', 30], ['larry', 40]]).object(); -result = _.remove([1, 2, 3, 4, 5, 6], function (num: number) { return num % 2 == 0; }); -result = _.remove(foodsOrganic, 'organic'); -result = _.remove(foodsType, { 'type': 'vegetable' }); -var typedResult: IFoodType[] = _.remove([ { name: 'apple' }, { name: 'orange' }], { name: 'orange' }); +// _.remove +module TestRemove { + let array: TResult[]; + let list: _.List; + let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; + let result: TResult[]; + + result = _.remove(array); + result = _.remove(array, predicateFn); + result = _.remove(array, predicateFn, any); + result = _.remove(array, ''); + result = _.remove(array, '', any); + result = _.remove<{a: number}, TResult>(array, {a: 42}); + + result = _.remove(list); + result = _.remove(list, predicateFn); + result = _.remove(list, predicateFn, any); + result = _.remove(list, ''); + result = _.remove(list, '', any); + result = _.remove<{a: number}, TResult>(list, {a: 42}); + + result = _(array).remove().value(); + result = _(array).remove(predicateFn).value(); + result = _(array).remove(predicateFn, any).value(); + result = _(array).remove('').value(); + result = _(array).remove('', any).value(); + result = _(array).remove<{a: number}>({a: 42}).value(); + + result = _(list).remove().value(); + result = _(list).remove(predicateFn).value(); + result = _(list).remove(predicateFn, any).value(); + result = _(list).remove('').value(); + result = _(list).remove('', any).value(); + result = _(list).remove<{a: number}, TResult>({a: 42}).value(); +} // _.slice { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 84a120f3b..49a6b51e6 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1023,72 +1023,97 @@ declare module _ { //_.remove interface LoDashStatic { /** - * Removes all elements from an array that the callback returns truey for and returns - * an array of removed elements. The callback is bound to thisArg and invoked with three - * arguments; (value, index, array). - * - * If a property name is provided for callback the created "_.pluck" style callback will - * return the property value of the given element. - * - * If an object is provided for callback the created "_.where" style callback will return - * true for elements that have the properties of the given object, else false. - * @param array The array to modify. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - * @return A new array of removed elements. - **/ - remove( - array: Array, - callback?: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.remove - **/ + * Removes all elements from array that predicate returns truthy for and returns an array of the removed + * elements. The predicate is bound to thisArg and invoked with three arguments: (value, index, array). + * + * If a property name is provided for predicate the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * Note: Unlike _.filter, this method mutates array. + * + * @param array The array to modify. + * @param predicate The function invoked per iteration. + * @param thisArg The this binding of predicate. + * @return Returns the new array of removed elements. + */ remove( array: List, - callback?: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.remove - * @param pluckValue _.pluck style callback - **/ - remove( - array: Array, - pluckValue?: string): T[]; - - /** - * @see _.remove - * @param pluckValue _.pluck style callback - **/ - remove( - array: List, - pluckValue?: string): T[]; - - /** - * @see _.remove - * @param whereValue _.where style callback - **/ - remove( - array: Array, - wherealue?: Dictionary): T[]; - - /** - * @see _.remove - * @param whereValue _.where style callback - **/ - remove( - array: List, - wherealue?: Dictionary): T[]; + predicate?: ListIterator, + thisArg?: any + ): T[]; /** * @see _.remove - * @param item The item to remove - **/ + */ remove( - array:Array, - item:T): T[]; + array: List, + predicate?: string, + thisArg?: any + ): T[]; + + /** + * @see _.remove + */ + remove( + array: List, + predicate?: W + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.remove + */ + remove( + predicate?: ListIterator, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: string, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: W + ): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.remove + */ + remove( + predicate?: ListIterator, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: string, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: W + ): LoDashArrayWrapper; } //_.rest