UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

45 lines (44 loc) 951 B
type IHumpObject = Record<string, any> | Array<any>; /** * 将对象中的key由下划线专为驼峰 * * @param {object} obj - 对象 * @returns {object} 转化后的对象 * * @example * const obj = { * a_a: 'a', * b_b: [ * { * bb_b: 'b', * }, * ], * c: { * dd_d: 'd', * e: { * ee_e: 'e', * }, * }, * }; * * toHumpObj(obj); * // { aA: 'a', bB: [ { bbB: 'b' } ], c: { ddD: 'd', e: { eeE: 'e' } } } */ export declare function toHumpObj(obj: IHumpObject, cache?: WeakMap<object, any>): object; /** * 将属性混合到目标对象中 * @param {object} to 目标对象 * @param {object} from 原始对象 * @returns 处理后的对象 * * @example * const a = { name: 'lee' } * const b = { age: 3 } * extend(a, b) * * console.log(a) * * // => { name: 'lee', age: 3 } */ export declare function extend(to: Record<string, any>, from: Record<string, any>): object; export {};