https://github.com/iagocalazans/nosep
This facilitates the conversion of object properties that have separators to the format used in JS
https://github.com/iagocalazans/nosep
modify objects sanitizer
Last synced: about 1 year ago
JSON representation
This facilitates the conversion of object properties that have separators to the format used in JS
- Host: GitHub
- URL: https://github.com/iagocalazans/nosep
- Owner: iagocalazans
- Created: 2021-07-06T21:06:19.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-06T22:07:45.000Z (almost 5 years ago)
- Last Synced: 2025-04-15T02:08:46.604Z (about 1 year ago)
- Topics: modify, objects, sanitizer
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/nosep
- Size: 6.84 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Welcome to No Separators (nosep) 👋
### This module facilitates the conversion of object properties that have separators to the format used in JS.
## Install
yarn users:
```sh
yarn add nosep
```
npm users:
```sh
npm install nosep
```
Importing:
```js
import { noSep } from 'nosep'
```
---
## Usage:
### Sanitize Object Properties
In the below object we have properties with the most varied forms of used separators. Let's call `.sanitizeProperties(obj, separator)` and check the result after application.
```js
const object = {'deploy#in-azure_dev-ops': false, 'deploy#in-dev_mode': true}
//noSep.sanitizeProperties(object[,separator])
/**
* camelCasing properties with default '_' (underscore)
*/
noSep.sanitizeProperties(object); // => { 'deploy#in-azureDev-ops': false, 'deploy#in-devMode': true }
/**
* camelCasing properties with '#'
*/
noSep.sanitizeProperties(object, '#'); // => { 'deployIn-azureDev-ops': false, 'deployIn-devMode': true }
/**
* camelCasing properties with '-'
*/
noSep.sanitizeProperties(object, '-'); // => { deployInAzureDevOps: false, deployInDevMode: true }
/**
* camelCasing properties with 'y' (letter)
*/
noSep.sanitizeProperties(object, 'y'); // => { deploInAzureDevOps: false, deploInDevMode: true }
```
---
## Aditional Usage:
### CamelCase string Array & Capitalize string
In addition we can use `.capitalize(string)` to generate a `camelCaseBased` string from an Array of strings, or simple Capitalize a string.
```js
// noSep.capitalize(string[,string[]])
/**
* camelCasing an Array of strings
*/
noSep.capitalize(['created', 'class', 'function']); // => createdClassFunction
/**
* Capitalizing the string "created"
*/
noSep.capitalize('created') // => Created
```
---
## Author
👤 **Iago Calazans** (💼 *Senior Node|TypeScript Developer*)
* Website: https://iagocalazans.github.io/
* GitHub: https://github.com/iagocalazans/