diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1d5525300..8bbfa68e0 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -650,6 +650,54 @@ result = _([1, 2]).zipWith([1, 2], [1, 2], [1, 2], [1, 2], [1, * Collection * **************/ +// _.all +module TestAll { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; + + let listIterator: (value: TResult, index: number, collection: _.List) => boolean; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean; + + let result: boolean; + + result = _.all(array); + result = _.all(array, listIterator); + result = _.all(array, listIterator, any); + result = _.all(array, ''); + result = _.all<{a: number}, TResult>(array, {a: 42}); + + result = _.all(list); + result = _.all(list, listIterator); + result = _.all(list, listIterator, any); + result = _.all(list, ''); + result = _.all<{a: number}, TResult>(list, {a: 42}); + + result = _.all(dictionary); + result = _.all(dictionary, dictionaryIterator); + result = _.all(dictionary, dictionaryIterator, any); + result = _.all(dictionary, ''); + result = _.all<{a: number}, TResult>(dictionary, {a: 42}); + + result = _(array).all(); + result = _(array).all(listIterator); + result = _(array).all(listIterator, any); + result = _(array).all(''); + result = _(array).all<{a: number}>({a: 42}); + + result = _(list).all(); + result = _(list).all(listIterator); + result = _(list).all(listIterator, any); + result = _(list).all(''); + result = _(list).all<{a: number}>({a: 42}); + + result = _(dictionary).all(); + result = _(dictionary).all(dictionaryIterator); + result = _(dictionary).all(dictionaryIterator, any); + result = _(dictionary).all(''); + result = _(dictionary).all<{a: number}>({a: 42}); +} + // _.at { let testAtArray: TResult[]; @@ -747,13 +795,53 @@ result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return this.floor(num); }, Math); result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).countBy('length'); -result = _.every([true, 1, null, 'yes'], Boolean); -result = _.every(stoogesAges, 'age'); -result = _.every(stoogesAges, { 'age': 50 }); +// _.every +module TestEvery { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; -result = _.all([true, 1, null, 'yes'], Boolean); -result = _.all(stoogesAges, 'age'); -result = _.all(stoogesAges, { 'age': 50 }); + let listIterator: (value: TResult, index: number, collection: _.List) => boolean; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => 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(list); + result = _.every(list, listIterator); + result = _.every(list, listIterator, any); + result = _.every(list, ''); + result = _.every<{a: number}, TResult>(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 = _(array).every(); + result = _(array).every(listIterator); + result = _(array).every(listIterator, any); + result = _(array).every(''); + 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<{a: number}>({a: 42}); + + result = _(dictionary).every(); + result = _(dictionary).every(dictionaryIterator); + result = _(dictionary).every(dictionaryIterator, any); + result = _(dictionary).every(''); + result = _(dictionary).every<{a: number}>({a: 42}); +} result = _.filter([1, 2, 3, 4, 5, 6]); result = _.filter([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 102811a16..19667ba4a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2004,6 +2004,94 @@ declare module _ { * Collection * **************/ + //_.all + interface LoDashStatic { + /** + * @see _.every + */ + all( + collection: List, + predicate?: ListIterator, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + collection: Dictionary, + predicate?: DictionaryIterator, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + collection: List|Dictionary, + predicate?: string, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + collection: List|Dictionary, + predicate?: TObject + ): boolean; + } + + interface LoDashArrayWrapper { + /** + * @see _.every + */ + all( + predicate?: ListIterator, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + predicate?: string, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + predicate?: TObject + ): boolean; + } + + interface LoDashObjectWrapper { + /** + * @see _.every + */ + all( + predicate?: ListIterator|DictionaryIterator, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + predicate?: string, + thisArg?: any + ): boolean; + + /** + * @see _.every + */ + all( + predicate?: TObject + ): boolean; + } + //_.at interface LoDashStatic { /** @@ -2383,162 +2471,106 @@ declare module _ { //_.every interface LoDashStatic { /** - * Checks if the given callback returns truey value for all elements of a collection. - * The callback is bound to thisArg and invoked with three arguments; (value, index|key, - * collection). - * - * 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 True if all elements passed the callback check, else false. - **/ - every( - collection: Array, - callback?: ListIterator, - thisArg?: any): boolean; - - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ + * 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. + * + * @alias _.all + * + * @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, - callback?: ListIterator, - thisArg?: any): boolean; + predicate?: ListIterator, + thisArg?: any + ): boolean; /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ + * @see _.every + */ every( collection: Dictionary, - callback?: DictionaryIterator, - thisArg?: any): boolean; + predicate?: DictionaryIterator, + thisArg?: any + ): boolean; /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ + * @see _.every + */ every( - collection: Array, - pluckValue: string): boolean; + collection: List|Dictionary, + predicate?: string, + thisArg?: any + ): boolean; /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - every( - collection: List, - pluckValue: string): boolean; + * @see _.every + */ + every( + collection: List|Dictionary, + predicate?: TObject + ): boolean; + } + + interface LoDashArrayWrapper { + /** + * @see _.every + */ + every( + predicate?: ListIterator, + thisArg?: any + ): boolean; /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - every( - collection: Dictionary, - pluckValue: string): boolean; + * @see _.every + */ + every( + predicate?: string, + thisArg?: any + ): boolean; /** - * @see _.every - * @param whereValue _.where style callback - **/ - every( - collection: Array, - whereValue: W): boolean; + * @see _.every + */ + every( + predicate?: TObject + ): boolean; + } + + interface LoDashObjectWrapper { + /** + * @see _.every + */ + every( + predicate?: ListIterator|DictionaryIterator, + thisArg?: any + ): boolean; /** - * @see _.every - * @param whereValue _.where style callback - **/ - every( - collection: List, - whereValue: W): boolean; + * @see _.every + */ + every( + predicate?: string, + thisArg?: any + ): boolean; /** - * @see _.every - * @param whereValue _.where style callback - **/ - every( - collection: Dictionary, - whereValue: W): boolean; - - /** - * @see _.every - **/ - all( - collection: Array, - callback?: ListIterator, - thisArg?: any): boolean; - - /** - * @see _.every - **/ - all( - collection: List, - callback?: ListIterator, - thisArg?: any): boolean; - - /** - * @see _.every - **/ - all( - collection: Dictionary, - callback?: DictionaryIterator, - thisArg?: any): boolean; - - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - all( - collection: Array, - pluckValue: string): boolean; - - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - all( - collection: List, - pluckValue: string): boolean; - - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - all( - collection: Dictionary, - pluckValue: string): boolean; - - /** - * @see _.every - * @param whereValue _.where style callback - **/ - all( - collection: Array, - whereValue: W): boolean; - - /** - * @see _.every - * @param whereValue _.where style callback - **/ - all( - collection: List, - whereValue: W): boolean; - - /** - * @see _.every - * @param whereValue _.where style callback - **/ - all( - collection: Dictionary, - whereValue: W): boolean; + * @see _.every + */ + every( + predicate?: TObject + ): boolean; } //_.fill