An open API service indexing awesome lists of open source software.

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.

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'
```