UNPKG

kubo-rpc-client-esm-cjs

Version:
34 lines 896 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.objectToCamel = void 0; /** * Convert object properties to camel case. * NOT recursive! * e.g. * AgentVersion => agentVersion * ID => id * * @param {Record<string, any>} obj */ function objectToCamel(obj) { if (obj == null) { return obj; } const caps = /^[A-Z]+$/; /** @type {Record<string, any>} */ const output = {}; return Object.keys(obj).reduce((camelObj, k) => { if (caps.test(k)) { // all caps camelObj[k.toLowerCase()] = obj[k]; } else if (caps.test(k[0])) { // pascal camelObj[k[0].toLowerCase() + k.slice(1)] = obj[k]; } else { camelObj[k] = obj[k]; } return camelObj; }, output); } exports.objectToCamel = objectToCamel; //# sourceMappingURL=object-to-camel.js.map