UNPKG
cpt-waffle-lotide
Version:
latest (1.0.0)
1.0.0
LoTide in Typescript
github.com/vasiliy-klimkin/lotide-ts
vasiliy-klimkin/lotide-ts
cpt-waffle-lotide
/
dist
/
flatten.ts
15 lines
(13 loc)
•
268 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const
flatten = (
array
:
any
[]):
any
[] => {
let
result
:
any
[] = [];
for
(
let
val
of
array) {
if
(
typeof
val ===
'number'
) { result.
push
(val); }
else
{
const
arr =
flatten
(val); result = [...result, ...arr]; } }
return
result; }
export
default
flatten;