From a50f64c12cb07631fdc0bc09b8bbea42fb435a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20S=C3=A1nchez?= Date: Mon, 29 Aug 2016 08:38:36 -0600 Subject: [PATCH] Add fromIndex parameter to find (#10789) --- lodash/lodash-tests.ts | 22 ++++++++++++++++++++-- lodash/lodash.d.ts | 32 +++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8ec22e98de..749d9ce972 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3674,33 +3674,51 @@ namespace TestFind { result = _.find(array); result = _.find(array, listIterator); + result = _.find(array, listIterator, 1); result = _.find(array, ''); + result = _.find(array, '', 1); result = _.find<{a: number}, TResult>(array, {a: 42}); + result = _.find<{a: number}, TResult>(array, {a: 42}, 1); result = _.find(list); result = _.find(list, listIterator); + result = _.find(list, listIterator, 1); result = _.find(list, ''); + result = _.find(list, '', 1); result = _.find<{a: number}, TResult>(list, {a: 42}); + result = _.find<{a: number}, TResult>(list, {a: 42}, 1); result = _.find(dictionary); result = _.find(dictionary, dictionaryIterator); + result = _.find(dictionary, dictionaryIterator, 1); result = _.find(dictionary, ''); + result = _.find(dictionary, '', 1); result = _.find<{a: number}, TResult>(dictionary, {a: 42}); + result = _.find<{a: number}, TResult>(dictionary, {a: 42}, 1); result = _(array).find(); result = _(array).find(listIterator); + result = _(array).find(listIterator, 1); result = _(array).find(''); + result = _(array).find('', 1); result = _(array).find<{a: number}>({a: 42}); + result = _(array).find<{a: number}>({a: 42}, 1); result = _(list).find(); result = _(list).find(listIterator); + result = _(list).find(listIterator, 1); result = _(list).find(''); + result = _(list).find('', 1); result = _(list).find<{a: number}, TResult>({a: 42}); + result = _(list).find<{a: number}, TResult>({a: 42}, 1); result = _(dictionary).find(); result = _(dictionary).find(dictionaryIterator); + result = _(dictionary).find(dictionaryIterator, 1); result = _(dictionary).find(''); + result = _(dictionary).find('', 1); result = _(dictionary).find<{a: number}, TResult>({a: 42}); + result = _(dictionary).find<{a: number}, TResult>({a: 42}, 1); } result = _.findLast([1, 2, 3, 4], function (num) { @@ -5733,11 +5751,11 @@ namespace TestFlow { let Fn2: (m: number, n: number) => number; let Fn3: (a: number) => string; let Fn4: (a: string) => number; - + { // type infer test let result: (m: number, n: number) => number; - + result = _.flow(Fn2, Fn1); result = _.flow(Fn2, Fn1, Fn1); result = _.flow(Fn2, Fn1, Fn1, Fn1); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index e64c868354..ea1a35a851 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6787,12 +6787,13 @@ declare module _ { * * @param collection The collection to search. * @param predicate The function invoked per iteration. - * @param thisArg The this binding of predicate. + * @param fromIndex The index to search from. * @return Returns the matched element, else undefined. */ find( collection: List, - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): T; /** @@ -6800,7 +6801,8 @@ declare module _ { */ find( collection: Dictionary, - predicate?: DictionaryIterator + predicate?: DictionaryIterator, + fromIndex?: number ): T; /** @@ -6808,7 +6810,8 @@ declare module _ { */ find( collection: List|Dictionary, - predicate?: string + predicate?: string, + fromIndex?: number ): T; /** @@ -6816,7 +6819,8 @@ declare module _ { */ find( collection: List|Dictionary, - predicate?: TObject + predicate?: TObject, + fromIndex?: number ): T; } @@ -6825,21 +6829,24 @@ declare module _ { * @see _.find */ find( - predicate?: ListIterator + predicate?: ListIterator, + fromIndex?: number ): T; /** * @see _.find */ find( - predicate?: string + predicate?: string, + fromIndex?: number ): T; /** * @see _.find */ find( - predicate?: TObject + predicate?: TObject, + fromIndex?: number ): T; } @@ -6848,21 +6855,24 @@ declare module _ { * @see _.find */ find( - predicate?: ListIterator|DictionaryIterator + predicate?: ListIterator|DictionaryIterator, + fromIndex?: number ): TResult; /** * @see _.find */ find( - predicate?: string + predicate?: string, + fromIndex?: number ): TResult; /** * @see _.find */ find( - predicate?: TObject + predicate?: TObject, + fromIndex?: number ): TResult; }