UNPKG

@leapfrogtechnology/db-model

Version:

Low-footprint database abstraction layer and model built on top of Knex.

65 lines (64 loc) 1.63 kB
/** * Recursively convert the object keys into camelCase. * * @param {any} obj * @returns {T} */ export declare function toCamelCase<T>(obj: any): T; /** * Recursively convert the object keys into snake_case. * * @param {any} obj * @returns {T} */ export declare function toSnakeCase<T>(obj: any): T; /** * Get the copy of list of objects without attributes. * * @param {any[]} obj * @param {any[]} attrsToExclude * @returns {T[]} */ export declare function listWithoutAttrs<T>(obj: any[], attrsToExclude: any[]): T[]; /** * Get the copy of object without attributes. * * @param {any} obj * @param {any[]} attrsToExclude * @returns {T} */ export declare function withoutAttrs<T>(obj: any, attrsToExclude: any[]): T; /** * Get the copy of object with only specified attributes. * * @param {any} obj * @param {any[]} attrs * @returns {T} */ export declare function withOnlyAttrs<T>(obj: any, attrs: any[]): T; /** * Parse JSON encoded string and return object with camelcase keys. * * @param {string} encoded * @returns {T} */ export declare function fromJson<T>(encoded: string): T; /** * Get number of keys from given value. * * @param {any} value * @returns {number} */ export declare function getKeysLength(value: any): number; /** * Checks whether two objects are partially equal. Two objects * are partially equal if one object is subset of another * objects. * E.g. a = { id: 1 } and b = { id: 1, name: 'John Doe' } * are partially equal. * * @param {object} a={} * @param {object} b={} * @returns {boolean} */ export declare function isPartiallyEqual(a: any, b: any): boolean;