camelcase-keys
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Camelcase-keys is a powerful JavaScript tool that allows developers to convert the keys of an object to camel case. Camel casing is a standard naming convention for variables in JavaScript where the first word starts with a lowercase letter, and any following words are directly attached but start with an uppercase letter (like "thisIsAnExample"). Camelcase-keys leverages the camelcase package under the hood to perform this conversion.
To utilize camelcase-keys in your code, follow these simple steps:
Install the package using npm with the command npm install camelcase-keys
.
Import it into your JavaScript file using import camelcaseKeys from 'camelcase-keys';
.
Now you can use camelcaseKeys()
function to convert the keys of an object or an array of objects to camel case. Here are a few examples:
To convert keys of an object:
camelcaseKeys({'foo-bar': true});
// Returns {fooBar: true}
To convert keys of an array of objects:
camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]);
// Returns [{fooBar: true}, {barFoo: false}]
Also, camelcase-keys provides an API to further customize the camel-casing conversion. You can exclude certain keys from conversion, decide if the function should recurse nested objects and arrays, use pascal case where the first letter of the string is also capitalized, preserve consecutive uppercase characters, and stop the function from camel-casing child objects at certain paths.
The official documentation for camelcase-keys reside in its repository README.md file on GitHub. The documentation provides detailed information about installation, usage, and API options that you can use to customize how camelcase-keys works.