'use strict'; import type { NestedArray } from './commonTypes'; export function flattenArray(array: NestedArray): T[] { if (!Array.isArray(array)) { return [array]; } const resultArr: T[] = []; const _flattenArray = (arr: NestedArray[]): void => { arr.forEach((item) => { if (Array.isArray(item)) { _flattenArray(item); } else { resultArr.push(item); } }); }; _flattenArray(array); return resultArr; } export const has = ( key: K, x: unknown ): x is { [key in K]: unknown } => { if (typeof x === 'function' || typeof x === 'object') { if (x === null || x === undefined) { return false; } else { return key in x; } } return false; };