File size: 324 Bytes
4d70170 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
export function flatten(items) {
return items.reduce((acc, item) => {
if (Array.isArray(item)) {
acc.push(...flatten(item))
}
else if (item) {
acc.push(item)
}
return acc
}, [])
}
export function returnError(cb: () => any) {
try {
return cb()
}
catch (e) {
return e
}
}
|