ipfs-http-client
Version:
A client library for the IPFS HTTP API
17 lines • 419 B
JavaScript
export function objectToCamel(obj) {
if (obj == null) {
return obj;
}
const caps = /^[A-Z]+$/;
const output = {};
return Object.keys(obj).reduce((camelObj, k) => {
if (caps.test(k)) {
camelObj[k.toLowerCase()] = obj[k];
} else if (caps.test(k[0])) {
camelObj[k[0].toLowerCase() + k.slice(1)] = obj[k];
} else {
camelObj[k] = obj[k];
}
return camelObj;
}, output);
}