flattenflatten 函数将一个嵌套数组“拉平”为指定深度的一维数组。
import { flatten } from '@movk/core'
const nested = [1, [2, 3], [4, [5, 6]]]
// 默认深度为 1
const flat1 = flatten(nested)
// => [1, 2, 3, 4, [5, 6]]
// 指定深度为 2
const flat2 = flatten(nested, 2)
// => [1, 2, 3, 4, 5, 6]
flatten<T>(arr: T[], depth = 1): any[]
1。