Skip to content

Commit

Permalink
reword some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Aug 16, 2024
1 parent a1a2635 commit 622eca3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions docs/array/flat.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
---
title: flat (deprecated)
title: flat
description: Flatten an array of arrays into a single dimension
---

:::caution[Deprecated]
This function is deprecated. Use `Array.prototype.flat` instead, which is widely available and supports both deep and shallow flattening.

[MDN: Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
:::

### Usage

Given an array that contains many arrays, return a new array where all items from the children are present at the top level.
Expand All @@ -16,9 +22,3 @@ _.flat(gods) // => [ra, loki, zeus]
```

Note, `_.flat` is not recursive and will not flatten children of children of children ... of children. It will only flatten `T[][]` an array of arrays.

:::caution
The `_.flat` function has been deprecated and will be removed in the next major release. Please use `Array.prototype.flat` which is widely available and supports both deep and shallow flattening.

[MDN Documentation for Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat)
:::
2 changes: 1 addition & 1 deletion src/array/flat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* // [1, 2, [3], 4, 5]
* ```
*
* @deprecated - use [Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) insted
* @deprecated Use [Array.prototype.flat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat) instead.
*/
export function flat<T>(lists: readonly T[][]): T[] {
return lists.flat()
Expand Down

0 comments on commit 622eca3

Please sign in to comment.