diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 84978683d..076fbd1bc 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3574,13 +3574,103 @@ result = _({ 'a': 1, 'b': 2, 'c': 3 }).inject(function (r: ABC result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); result = _.foldr([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); -result = _.reject([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); -result = _.reject(foodsCombined, 'organic'); -result = _.reject(foodsCombined, { 'type': 'fruit' }); +// _.reject +module TestReject { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; -result = _([1, 2, 3, 4, 5, 6]).reject(function (num) { return num % 2 == 0; }).value(); -result = _(foodsCombined).reject('organic').value(); -result = _(foodsCombined).reject({ 'type': 'fruit' }).value(); + let stringIterator: (char: string, index: number, string: string) => any; + let listIterator: (value: TResult, index: number, collection: _.List) => any; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; + + { + let result: string[]; + + result = _.reject('', stringIterator); + result = _.reject('', stringIterator, any); + } + + { + let result: TResult[]; + + result = _.reject(array, listIterator); + result = _.reject(array, listIterator, any); + result = _.reject(array, ''); + result = _.reject(array, '', any); + result = _.reject<{a: number}, TResult>(array, {a: 42}); + + result = _.reject(list, listIterator); + result = _.reject(list, listIterator, any); + result = _.reject(list, ''); + result = _.reject(list, '', any); + result = _.reject<{a: number}, TResult>(list, {a: 42}); + + result = _.reject(dictionary, dictionaryIterator); + result = _.reject(dictionary, dictionaryIterator, any); + result = _.reject(dictionary, ''); + result = _.reject(dictionary, '', any); + result = _.reject<{a: number}, TResult>(dictionary, {a: 42}); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _('').reject(stringIterator); + result = _('').reject(stringIterator, any); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).reject(listIterator); + result = _(array).reject(listIterator, any); + result = _(array).reject(''); + result = _(array).reject('', any); + result = _(array).reject<{a: number}>({a: 42}); + + result = _(list).reject(listIterator); + result = _(list).reject(listIterator, any); + result = _(list).reject(''); + result = _(list).reject('', any); + result = _(list).reject<{a: number}, TResult>({a: 42}); + + result = _(dictionary).reject(dictionaryIterator); + result = _(dictionary).reject(dictionaryIterator, any); + result = _(dictionary).reject(''); + result = _(dictionary).reject('', any); + result = _(dictionary).reject<{a: number}, TResult>({a: 42}); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _('').chain().reject(stringIterator); + result = _('').chain().reject(stringIterator, any); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().reject(listIterator); + result = _(array).chain().reject(listIterator, any); + result = _(array).chain().reject(''); + result = _(array).chain().reject('', any); + result = _(array).chain().reject<{a: number}>({a: 42}); + + result = _(list).chain().reject(listIterator); + result = _(list).chain().reject(listIterator, any); + result = _(list).chain().reject(''); + result = _(list).chain().reject('', any); + result = _(list).chain().reject<{a: number}, TResult>({a: 42}); + + result = _(dictionary).chain().reject(dictionaryIterator); + result = _(dictionary).chain().reject(dictionaryIterator, any); + result = _(dictionary).chain().reject(''); + result = _(dictionary).chain().reject('', any); + result = _(dictionary).chain().reject<{a: number}, TResult>({a: 42}); + } +} result = _.sample([1, 2, 3, 4]); result = _.sample([1, 2, 3, 4], 2); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index e0d14e975..964b9f966 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6431,108 +6431,166 @@ declare module _ { //_.reject interface LoDashStatic { /** - * The opposite of _.filter this method returns the elements of a collection that - * the callback does not return truey for. - * - * 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 collection The collection to iterate over. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - * @return A new array of elements that failed the callback check. - **/ - reject( - collection: Array, - callback: ListIterator, - thisArg?: any): T[]; - - /** - * @see _.reject - **/ + * The opposite of _.filter; this method returns the elements of collection that predicate does not return + * truthy for. + * + * @param collection The collection to iterate over. + * @param predicate The function invoked per iteration. + * @param thisArg The this binding of predicate. + * @return Returns the new filtered array. + */ reject( collection: List, - callback: ListIterator, - thisArg?: any): T[]; + predicate?: ListIterator, + thisArg?: any + ): T[]; /** - * @see _.reject - **/ + * @see _.reject + */ reject( collection: Dictionary, - callback: DictionaryIterator, - thisArg?: any): T[]; + predicate?: DictionaryIterator, + thisArg?: any + ): T[]; /** - * @see _.reject - * @param pluckValue _.pluck style callback - **/ + * @see _.reject + */ + reject( + collection: string, + predicate?: StringIterator, + thisArg?: any + ): string[]; + + /** + * @see _.reject + */ reject( - collection: Array, - pluckValue: string): T[]; + collection: List|Dictionary, + predicate: string, + thisArg?: any + ): T[]; /** - * @see _.reject - * @param pluckValue _.pluck style callback - **/ - reject( - collection: List, - pluckValue: string): T[]; + * @see _.reject + */ + reject( + collection: List|Dictionary, + predicate: W + ): T[]; + } + interface LoDashImplicitWrapper { /** - * @see _.reject - * @param pluckValue _.pluck style callback - **/ - reject( - collection: Dictionary, - pluckValue: string): T[]; - - /** - * @see _.reject - * @param whereValue _.where style callback - **/ - reject( - collection: Array, - whereValue: W): T[]; - - /** - * @see _.reject - * @param whereValue _.where style callback - **/ - reject( - collection: List, - whereValue: W): T[]; - - /** - * @see _.reject - * @param whereValue _.where style callback - **/ - reject( - collection: Dictionary, - whereValue: W): T[]; + * @see _.reject + */ + reject( + predicate?: StringIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; } interface LoDashImplicitArrayWrapper { /** - * @see _.reject - **/ + * @see _.reject + */ reject( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + predicate: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.reject - * @param pluckValue _.pluck style callback - **/ - reject(pluckValue: string): LoDashImplicitArrayWrapper; + * @see _.reject + */ + reject( + predicate: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; /** - * @see _.reject - * @param whereValue _.where style callback - **/ - reject(whereValue: W): LoDashImplicitArrayWrapper; + * @see _.reject + */ + reject(predicate: W): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.reject + */ + reject( + predicate: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.reject + */ + reject( + predicate: string, + thisArg?: any + ): LoDashImplicitArrayWrapper; + + /** + * @see _.reject + */ + reject(predicate: W): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitWrapper { + /** + * @see _.reject + */ + reject( + predicate?: StringIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.reject + */ + reject( + predicate: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.reject + */ + reject( + predicate: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.reject + */ + reject(predicate: W): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.reject + */ + reject( + predicate: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.reject + */ + reject( + predicate: string, + thisArg?: any + ): LoDashExplicitArrayWrapper; + + /** + * @see _.reject + */ + reject(predicate: W): LoDashExplicitArrayWrapper; } //_.sample