diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 4f84b49380..14efc9c008 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -253,11 +253,15 @@ result = >_.flatten([1, [2], [[3]]], true); result = >_.flatten([1, [2], [3, [[4]]]], true); result = >_.flatten([1, [2], [3, [[false]]]], true); +result = >_.flattenDeep([[[[1]]]]); + result = <_.LoDashArrayWrapper>_([[1, 2], [3, 4], 5, 6]).flatten(); result = <_.LoDashArrayWrapper>>>_([1, [2], [3, [[4]]]]).flatten(); result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); +result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flattenDeep(); + result = _.indexOf([1, 2, 3, 1, 2, 3], 2); result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 53447ed4ab..ea93f2e70c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -800,7 +800,9 @@ declare module _ { //_.flatten interface LoDashStatic { /** - * Flattens a nested array. + * Flattens a nested array a single level. + * + * _.flatten(x) is equivalent to _.flatten(x, false); * * @param array The array to flatten. * @return `array` flattened. @@ -811,11 +813,24 @@ declare module _ { * Flattens a nested array. If isDeep is true the array is recursively flattened, otherwise it is only * flattened a single level. * + * If you know whether or not this should be recursively at compile time, you typically want to use a + * version without a boolean parameter (i.e. `_.flatten(x)` or `_.flattenDeep(x)`). + * * @param array The array to flatten. * @param deep Specify a deep flatten. * @return `array` flattened. **/ flatten(array: RecursiveList, isDeep: boolean): List | RecursiveList; + + /** + * Recursively flattens a nested array. + * + * _.flattenDeep(x) is equivalent to _.flatten(x, true); + * + * @param array The array to flatten + * @return `array` recursively flattened + */ + flattenDeep(array: RecursiveList): List } interface LoDashArrayWrapper { @@ -825,9 +840,14 @@ declare module _ { flatten(): LoDashArrayWrapper; /** - * @see _.flatten - **/ + * @see _.flatten + **/ flatten(isShallow: boolean): LoDashArrayWrapper; + + /** + * @see _.flattenDeep + */ + flattenDeep(): LoDashArrayWrapper; } //_.indexOf