INNER CODE UNIT · TypeScript

addPrefixToProperties

OS-Guild/graphql-to-mongodb · src/common.ts:136

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 {
    return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date);
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…