humps
humps copied to clipboard
Camelize keys & uppercase
I noticed that some uppercased keys were camelized in a weird way:
humps.camelizeKeys({ "USERNAME": "foo" }) // returns { uSERNAME: "foo" }
I've used a custom function & lodash to prevent this from happening, but I was wondering if that was the expected behaviour from humps.
// Use lowercase instead of camelization for uppercase-only keys
// (to prevent USERNAME from becoming uSERNAME)
humps.camelizeKeys(data, function (key, convert, options) {
return /^[A-Z0-9_]+$/.test(key) ? lowerCase(key) : convert(key, options);
});