diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index eb623a4709..4ecc5886a4 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -205,6 +205,16 @@ result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); result = _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); result = _.at(['moe', 'larry', 'curly'], 0, 2); +result = _.contains([1, 2, 3], 1); +result = _.contains([1, 2, 3], 1, 2); +result = _.contains({ 'name': 'moe', 'age': 40 }, 'moe'); +result = _.contains('curly', 'ur'); + + result = _.include([1, 2, 3], 1); + result = _.include([1, 2, 3], 1, 2); + result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); + result = _.include('curly', 'ur'); + result = _.every([true, 1, null, 'yes'], Boolean); result = _.every(stoogesAges, 'age'); result = _.every(stoogesAges, { 'age': 50 }); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index f48beecfc4..e0028334b5 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -785,6 +785,62 @@ declare module _ { collection: Collection, ...indexes: number[]): T[]; + /** + * Checks if a given value is present in a collection using strict equality for comparisons, + * i.e. ===. If fromIndex is negative, it is used as the offset from the end of the collection. + * @param collection The collection to iterate over. + * @param target The value to check for. + * @param fromIndex The index to search from. + * @return True if the target element is found, else false. + **/ + export function contains( + collection: Collection, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + * @param dictionary The dictionary to iterate over. + * @param key The key in the dictionary to search for. + **/ + export function contains( + dictionary: Dictionary, + key: string, + fromIndex?: number): boolean; + + /** + * @see _.contains + * @param searchString the string to search + * @param targetString the string to search for + **/ + export function contains( + searchString: string, + targetString: string, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + export function include( + collection: Collection, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + export function include( + dictionary: Dictionary, + key: string, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + export function include( + searchString: string, + targetString: string, + fromIndex?: number): boolean; /** * Checks if the given callback returns truey value for all elements of a collection. @@ -1176,23 +1232,7 @@ declare module _ { - /** - * Returns true if the value is present in the list. Uses indexOf internally, - * if list is an Array. - * @param list Checks each element to see if `value` is present. - * @param value The value to check for within `list`. - * @return True if `value` is present in `list`, otherwise false. - **/ - export function contains( - list: Collection, - value: T): boolean; - - /** - * @see _.contains - **/ - export function include( - list: Collection, - value: T): boolean; + /** * Calls the method named by methodName on each value in the list. Any extra arguments passed to