INNER CODE UNIT · TypeScript
flatten
OS-Guild/graphql-to-mongodb · src/common.ts:132
export function flatten<T>(nestedArray: T[][]): T[] {
return nestedArray.reduce((agg, b) => agg.concat(b), []);
}
export function addPrefixToProperties<T extends {}>(obj: T, prefix: string): T {
return Object.keys(obj).reduce((agg, key) => ({ ...agg, [`${prefix}${key}`]: obj[key] }), {}) as T;
}
export function isPrimitive(value: any): boolean {
const type = typeof value;
return (type === "boolean"
|| type === "number"
|| type === "string"
|| type === "undefined"
|| (type === "object" && (value === null || isValidDate(value))));
}
function isValidDate(date): boolean {