2022-02-04 00:13:04 +00:00
|
|
|
export function filterDefined<T>(array: (T | null | undefined)[]) {
|
2022-03-24 17:03:08 +00:00
|
|
|
return array.filter((item) => item !== null && item !== undefined) as T[]
|
2022-02-04 00:13:04 +00:00
|
|
|
}
|
2022-08-10 17:17:33 +00:00
|
|
|
|
|
|
|
export function buildArray<T>(
|
|
|
|
...params: (T | T[] | false | undefined | null)[]
|
|
|
|
) {
|
|
|
|
const array: T[] = []
|
|
|
|
|
|
|
|
for (const el of params) {
|
|
|
|
if (Array.isArray(el)) {
|
|
|
|
array.push(...el)
|
|
|
|
} else if (el) {
|
|
|
|
array.push(el)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return array
|
|
|
|
}
|