https://github.com/lavesan/val-utils
Utils that i make
https://github.com/lavesan/val-utils
case-converter javascript utils-lib
Last synced: 2 months ago
JSON representation
Utils that i make
- Host: GitHub
- URL: https://github.com/lavesan/val-utils
- Owner: lavesan
- Created: 2019-10-20T22:07:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T16:49:54.000Z (over 2 years ago)
- Last Synced: 2024-04-28T05:46:51.232Z (about 1 year ago)
- Topics: case-converter, javascript, utils-lib
- Language: JavaScript
- Size: 169 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Val Utils
I created this utils repo to make functions/consts that helps developers like me in many ways.
If you have some troubles's idea, feel free to talk to me or make a fork with a pull request with a solution on my repo!
## Using
Just install this library from npm
```bash
npm i --save val-utils
```and then import the function you want:
```javascript
import { camelToSnakeCase } from 'val-utils';
```## Functions
### camelToSnakeCase
Transforms the key names of a object from camel case to snake case
Example:
```javascript
const camelCaseObject = {
userId: 1,
userEmail: '[email protected]',
userPassword: 'rds@%%$#$das!',
userData: {
userAccount: 1234,
userDv: 1,
userAgency: 123,
}
};console.log(camelToSnakeCase(camelCaseObject));
/**
* Output:
* {
* user_id: 1,
* user_email: '[email protected]',
* user_password: 'rds@%%$#$das!',
* user_data: {
* user_account: 1234,
* user_dv: 1,
* user_agency: 123,
* }
* }
* /
```### snakeToCamelCase
Transform the key names of a object from snake case to camel case
Example:
```javascript
const snakeCaseObject = {
user_id: 1,
user_email: '[email protected]',
user_password: 'rds@%%$#$das!',
user_data: {
user_account: 1234,
user_dv: 1,
user_agency: 123,
}
};console.log(snakeToCamelCase(snakeCaseObject));
/**
* Output:
* {
* userId: 1,
* userEmail: '[email protected]',
* userPassword: 'rds@%%$#$das!',
* userData: {
* userAccount: 1234,
* userDv: 1,
* userAgency: 123,
* }
* }
* /
```