https://github.com/chnb128/oh-my-case
Recursive case to case conversion
https://github.com/chnb128/oh-my-case
camel-case camelcase camelcase-keys-object camelcase-to-snakecase snake-case snakecase snakecase-keys-object snakecase-to-camelcase
Last synced: about 2 months ago
JSON representation
Recursive case to case conversion
- Host: GitHub
- URL: https://github.com/chnb128/oh-my-case
- Owner: CHNB128
- Created: 2020-08-21T20:08:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-22T11:20:10.000Z (over 4 years ago)
- Last Synced: 2025-03-14T23:04:24.936Z (2 months ago)
- Topics: camel-case, camelcase, camelcase-keys-object, camelcase-to-snakecase, snake-case, snakecase, snakecase-keys-object, snakecase-to-camelcase
- Language: JavaScript
- Homepage:
- Size: 120 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Oh my cases
Library to recursively convert any types from any cases to destination one
## Install
npm
```shell
npm install oh-my-cases
```yarn
```shell
yarn add oh-my-cases
```## Usage
```js
import { snakeToCamel } from 'oh-my-cases'snakeToCamel('snake_case') // => 'snakeCase'
snakeToCamel({'snake_case': 11}) // => {'snakeCase': 11}
```## How to contribute
To add support for new case, just add two functions like `snakeStringtoCamel` and `snakeToCamel` into `index.js` and export function for case conversion.
Don't forgot about tests.Example for `camelCase`:
```js
// index.jsconst snakeStringToCamel = (value) => {
return value.replace(/_(\w)/g, (m) => m[1].toUpperCase())
}const snakeToCamel = toCase(snakeStringToCamel)
module.exports = {
// ...
snakeToCamel
// ...
}
```Then make a Pull Request and thanks to you for help grow open source :)