What is @types/humps?
@types/humps is a TypeScript type definition package for the humps library, which provides utilities for converting object keys between camelCase, snake_case, and other formats. This is particularly useful for working with APIs that use different naming conventions.
What are @types/humps's main functionalities?
camelizeKeys
Converts the keys of an object from snake_case to camelCase.
const humps = require('humps');
const input = { first_name: 'John', last_name: 'Doe' };
const output = humps.camelizeKeys(input);
console.log(output); // { firstName: 'John', lastName: 'Doe' }
decamelizeKeys
Converts the keys of an object from camelCase to snake_case.
const humps = require('humps');
const input = { firstName: 'John', lastName: 'Doe' };
const output = humps.decamelizeKeys(input);
console.log(output); // { first_name: 'John', last_name: 'Doe' }
camelize
Converts a string from snake_case to camelCase.
const humps = require('humps');
const input = 'hello_world';
const output = humps.camelize(input);
console.log(output); // 'helloWorld'
decamelize
Converts a string from camelCase to snake_case.
const humps = require('humps');
const input = 'helloWorld';
const output = humps.decamelize(input);
console.log(output); // 'hello_world'
Other packages similar to @types/humps
lodash
Lodash is a popular utility library that provides a wide range of functions for manipulating arrays, objects, and other data types. It includes methods like _.camelCase and _.snakeCase for converting strings between different cases. However, it is a much larger library with a broader scope compared to humps.
change-case
The change-case package provides a collection of functions for changing the case of strings, such as camelCase, snake_case, and others. It is more focused on string manipulation and does not provide utilities for converting object keys like humps does.
case-converter
case-converter is a lightweight library specifically designed for converting object keys between different cases, similar to humps. It offers similar functionality but may have a different API and fewer features compared to humps.