Created
November 21, 2024 01:50
-
-
Save ghostdevv/1ec0768384d068fc18fa9416de4539e6 to your computer and use it in GitHub Desktop.
Revisions
-
ghostdevv created this gist
Nov 21, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ function flat<T extends any[], D extends number = 1>(array: T, depth?: D): FlatArray<T, D>[] { return typeof depth == 'undefined' || depth > 0 ? array.reduce((a, x) => a.concat(Array.isArray(x) ? flat(x, (depth ?? 1) - 1) : x), []) : array }