README.md
 1  # toidentifier
 2  
 3  [![NPM Version][npm-image]][npm-url]
 4  [![NPM Downloads][downloads-image]][downloads-url]
 5  [![Build Status][github-actions-ci-image]][github-actions-ci-url]
 6  [![Test Coverage][codecov-image]][codecov-url]
 7  
 8  > Convert a string of words to a JavaScript identifier
 9  
10  ## Install
11  
12  This is a [Node.js](https://nodejs.org/en/) module available through the
13  [npm registry](https://www.npmjs.com/). Installation is done using the
14  [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
15  
16  ```bash
17  $ npm install toidentifier
18  ```
19  
20  ## Example
21  
22  ```js
23  var toIdentifier = require('toidentifier')
24  
25  console.log(toIdentifier('Bad Request'))
26  // => "BadRequest"
27  ```
28  
29  ## API
30  
31  This CommonJS module exports a single default function: `toIdentifier`.
32  
33  ### toIdentifier(string)
34  
35  Given a string as the argument, it will be transformed according to
36  the following rules and the new string will be returned:
37  
38  1. Split into words separated by space characters (`0x20`).
39  2. Upper case the first character of each word.
40  3. Join the words together with no separator.
41  4. Remove all non-word (`[0-9a-z_]`) characters.
42  
43  ## License
44  
45  [MIT](LICENSE)
46  
47  [codecov-image]: https://img.shields.io/codecov/c/github/component/toidentifier.svg
48  [codecov-url]: https://codecov.io/gh/component/toidentifier
49  [downloads-image]: https://img.shields.io/npm/dm/toidentifier.svg
50  [downloads-url]: https://npmjs.org/package/toidentifier
51  [github-actions-ci-image]: https://img.shields.io/github/workflow/status/component/toidentifier/ci/master?label=ci
52  [github-actions-ci-url]: https://github.com/component/toidentifier?query=workflow%3Aci
53  [npm-image]: https://img.shields.io/npm/v/toidentifier.svg
54  [npm-url]: https://npmjs.org/package/toidentifier
55  
56  
57  ##
58  
59  [npm]: https://www.npmjs.com/
60  
61  [yarn]: https://yarnpkg.com/