https://github.com/peterroe/name-transform
A tiny library for transforming names.
https://github.com/peterroe/name-transform
Last synced: 9 months ago
JSON representation
A tiny library for transforming names.
- Host: GitHub
- URL: https://github.com/peterroe/name-transform
- Owner: peterroe
- Created: 2022-04-24T10:11:37.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-26T08:06:46.000Z (almost 4 years ago)
- Last Synced: 2023-03-04T01:14:00.412Z (over 3 years ago)
- Language: TypeScript
- Homepage:
- Size: 70.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## name-transform
A tiny library for transforming names.
## Features
* Tiny size
* `Typescript` support
* `umd` and `esm`
## Usage
```shell
npm install name-transform
```
```js
/*
camel --> 'helloWorld'
pascal --> 'HelloWorld'
hyphen --> 'hello-world'
underscore --> 'hello_world'
*/
import {
camelToHyphen,
camelToPascal,
camelToUnderscore,
pascalToCamel,
pascalToHyphen,
pascalToUnderscore,
underscoreToCamel,
underscoreToHyphen,
underscoreToPascal,
} from 'name-transform'
// or const { camelToHyphen, ... } = require('name-transform')
camelToUnderscore('helloWorld') // =>'hello_world'
camelToPascal('helloWorld') // =>'HelloWorld'
camelToHyphen('helloWorld') // =>'hello-world'
pascalToCamel('HelloWorld') // =>'helloWorld'
pascalToHyphen('HelloWorld') // =>'hello-world'
pascalToUnderscore('HelloWorld') // =>'hello_world'
underscoreToCamel('hello_world') // =>'helloWorld'
underscoreToPascal('hello_world') // =>'HelloWorld'
underscoreToHyphen('hello_world') // =>'hello-world'
```