diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 49974a788..85dbdd536 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3407,52 +3407,68 @@ module TestEachRight { } // _.every -module TestEvery { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; +namespace TestEvery { + type SampleObject = {a: number; b: string; c: boolean;}; - let listIterator: (value: TResult, index: number, collection: _.List) => boolean; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean; + let array: SampleObject[]; + let list: _.List; + let dictionary: _.Dictionary; + let numericDictionary: _.NumericDictionary; + + let listIterator: (value: SampleObject, index: number, collection: _.List) => boolean; + let dictionaryIterator: (value: SampleObject, key: string, collection: _.Dictionary) => boolean; + let numericDictionaryIterator: (value: SampleObject, key: number, collection: _.NumericDictionary) => boolean; { let result: boolean; - result = _.every(array); - result = _.every(array, listIterator); - result = _.every(array, listIterator, any); - result = _.every(array, ''); - result = _.every<{a: number}, TResult>(array, {a: 42}); + result = _.every(array); + result = _.every(array, listIterator); + result = _.every(array, 'a'); + result = _.every(array, ['a', 42]); + result = _.every<{a: number}, SampleObject>(array, {a: 42}); - result = _.every(list); - result = _.every(list, listIterator); - result = _.every(list, listIterator, any); - result = _.every(list, ''); - result = _.every<{a: number}, TResult>(list, {a: 42}); + result = _.every(list); + result = _.every(list, listIterator); + result = _.every(list, 'a'); + result = _.every(list, ['a', 42]); + result = _.every<{a: number}, SampleObject>(list, {a: 42}); - result = _.every(dictionary); - result = _.every(dictionary, dictionaryIterator); - result = _.every(dictionary, dictionaryIterator, any); - result = _.every(dictionary, ''); - result = _.every<{a: number}, TResult>(dictionary, {a: 42}); + result = _.every(dictionary); + result = _.every(dictionary, dictionaryIterator); + result = _.every(dictionary, 'a'); + result = _.every(dictionary, ['a', 42]); + result = _.every<{a: number}, SampleObject>(dictionary, {a: 42}); + + result = _.every(numericDictionary); + result = _.every(numericDictionary, numericDictionaryIterator); + result = _.every(numericDictionary, 'a'); + result = _.every(numericDictionary, ['a', 42]); + result = _.every<{a: number}, SampleObject>(numericDictionary, {a: 42}); result = _(array).every(); result = _(array).every(listIterator); - result = _(array).every(listIterator, any); - result = _(array).every(''); + result = _(array).every('a'); + result = _(array).every(['a', 42]); result = _(array).every<{a: number}>({a: 42}); - result = _(list).every(); - result = _(list).every(listIterator); - result = _(list).every(listIterator, any); - result = _(list).every(''); + result = _(list).every(); + result = _(list).every(listIterator); + result = _(list).every('a'); + result = _(list).every(['a', 42]); result = _(list).every<{a: number}>({a: 42}); - result = _(dictionary).every(); - result = _(dictionary).every(dictionaryIterator); - result = _(dictionary).every(dictionaryIterator, any); - result = _(dictionary).every(''); + result = _(dictionary).every(); + result = _(dictionary).every(dictionaryIterator); + result = _(dictionary).every('a'); + result = _(dictionary).every(['a', 42]); result = _(dictionary).every<{a: number}>({a: 42}); + + result = _(numericDictionary).every(); + result = _(numericDictionary).every(numericDictionaryIterator); + result = _(numericDictionary).every('a'); + result = _(numericDictionary).every(['a', 42]); + result = _(numericDictionary).every<{a: number}>({a: 42}); } { @@ -3460,21 +3476,27 @@ module TestEvery { result = _(array).chain().every(); result = _(array).chain().every(listIterator); - result = _(array).chain().every(listIterator, any); - result = _(array).chain().every(''); + result = _(array).chain().every('a'); + result = _(array).chain().every(['a', 42]); result = _(array).chain().every<{a: number}>({a: 42}); - result = _(list).chain().every(); - result = _(list).chain().every(listIterator); - result = _(list).chain().every(listIterator, any); - result = _(list).chain().every(''); + result = _(list).chain().every(); + result = _(list).chain().every(listIterator); + result = _(list).chain().every('a'); + result = _(list).chain().every(['a', 42]); result = _(list).chain().every<{a: number}>({a: 42}); - result = _(dictionary).chain().every(); - result = _(dictionary).chain().every(dictionaryIterator); - result = _(dictionary).chain().every(dictionaryIterator, any); - result = _(dictionary).chain().every(''); + result = _(dictionary).chain().every(); + result = _(dictionary).chain().every(dictionaryIterator); + result = _(dictionary).chain().every('a'); + result = _(dictionary).chain().every(['a', 42]); result = _(dictionary).chain().every<{a: number}>({a: 42}); + + result = _(numericDictionary).chain().every(); + result = _(numericDictionary).chain().every(numericDictionaryIterator); + result = _(numericDictionary).chain().every('a'); + result = _(numericDictionary).chain().every(['a', 42]); + result = _(numericDictionary).chain().every<{a: number}>({a: 42}); } } diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index c3af67d28..97e576da5 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6049,27 +6049,16 @@ declare module _ { //_.every interface LoDashStatic { /** - * Checks if predicate returns truthy for all elements of collection. The predicate is bound to thisArg and - * invoked with three arguments: (value, index|key, collection). - * - * 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. + * Checks if predicate returns truthy for all elements of collection. Iteration is stopped once predicate + * returns falsey. The predicate is invoked with three arguments: (value, index|key, collection). * * @param collection The collection to iterate over. * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. * @return Returns true if all elements pass the predicate check, else false. */ every( collection: List, - predicate?: ListIterator, - thisArg?: any + predicate?: ListIterator ): boolean; /** @@ -6077,24 +6066,30 @@ declare module _ { */ every( collection: Dictionary, - predicate?: DictionaryIterator, - thisArg?: any + predicate?: DictionaryIterator ): boolean; /** * @see _.every */ every( - collection: List|Dictionary, - predicate?: string, - thisArg?: any + collection: NumericDictionary, + predicate?: NumericDictionaryIterator + ): boolean; + + /** + * @see _.every + */ + every( + collection: List|Dictionary|NumericDictionary, + predicate?: string|any[] ): boolean; /** * @see _.every */ every( - collection: List|Dictionary, + collection: List|Dictionary|NumericDictionary, predicate?: TObject ): boolean; } @@ -6104,16 +6099,14 @@ declare module _ { * @see _.every */ every( - predicate?: ListIterator, - thisArg?: any + predicate?: ListIterator|NumericDictionaryIterator ): boolean; /** * @see _.every */ every( - predicate?: string, - thisArg?: any + predicate?: string|any[] ): boolean; /** @@ -6129,16 +6122,14 @@ declare module _ { * @see _.every */ every( - predicate?: ListIterator|DictionaryIterator, - thisArg?: any + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator ): boolean; /** * @see _.every */ every( - predicate?: string, - thisArg?: any + predicate?: string|any[] ): boolean; /** @@ -6154,16 +6145,14 @@ declare module _ { * @see _.every */ every( - predicate?: ListIterator, - thisArg?: any + predicate?: ListIterator|NumericDictionaryIterator ): LoDashExplicitWrapper; /** * @see _.every */ every( - predicate?: string, - thisArg?: any + predicate?: string|any[] ): LoDashExplicitWrapper; /** @@ -6179,16 +6168,14 @@ declare module _ { * @see _.every */ every( - predicate?: ListIterator|DictionaryIterator, - thisArg?: any + predicate?: ListIterator|DictionaryIterator|NumericDictionaryIterator ): LoDashExplicitWrapper; /** * @see _.every */ every( - predicate?: string, - thisArg?: any + predicate?: string|any[] ): LoDashExplicitWrapper; /**