1 | stringcase
|
2 | ==========
|
3 |
|
4 |
|
5 | <a name="badges"></a>
|
6 |
|
7 | [![Build Status][bd_travis_shield_url]][bd_travis_url]
|
8 | [![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
|
9 | [![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
|
10 | [![npm Version][bd_npm_shield_url]][bd_npm_url]
|
11 |
|
12 | [bd_repo_url]: https://github.com/okunishinishi/node-stringcase
|
13 | [bd_travis_url]: http://travis-ci.org/okunishinishi/node-stringcase
|
14 | [bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-stringcase.svg?style=flat
|
15 | [bd_license_url]: https://github.com/okunishinishi/node-stringcase/blob/master/LICENSE
|
16 | [bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-stringcase
|
17 | [bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-stringcase.svg?style=flat
|
18 | [bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-stringcase.svg?style=flat
|
19 | [bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-stringcase
|
20 | [bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-stringcase.svg
|
21 | [bd_npm_url]: http://www.npmjs.org/package/stringcase
|
22 | [bd_npm_shield_url]: http://img.shields.io/npm/v/stringcase.svg?style=flat
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | <a name="description"></a>
|
29 |
|
30 | Convert string cases between camel case, pascal case, snake case etc...
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | <a name="sections"></a>
|
38 |
|
39 | Installation
|
40 | -----
|
41 |
|
42 | ```bash
|
43 | npm install stringcase --save
|
44 | ```
|
45 |
|
46 | Usage
|
47 | -------
|
48 |
|
49 | ```Javascript
|
50 | var stringcase = require('stringcase');
|
51 |
|
52 | //------------------------
|
53 | // Convert to camelcase
|
54 | //------------------------
|
55 | stringcase.camelcase('foo_bar'); // => "fooBar"
|
56 | stringcase.camelcase('FOO_BAR'); // => "fooBar"
|
57 | stringcase.camelcase('fooBar'); // => "fooBar"
|
58 | stringcase.camelcase('FooBar'); // => "fooBar"
|
59 |
|
60 |
|
61 | //------------------------
|
62 | // Convert to capitalcase
|
63 | //------------------------
|
64 | stringcase.capitalcase('foo_bar'); // => "Foo_bar"
|
65 | stringcase.capitalcase('FOO_BAR'); // => "FOO_BAR"
|
66 | stringcase.capitalcase('fooBar'); // => "FooBar"
|
67 | stringcase.capitalcase('FooBar'); // => "FooBar"
|
68 |
|
69 |
|
70 | //------------------------
|
71 | // Convert to constcase
|
72 | //------------------------
|
73 | stringcase.constcase('foo_bar'); // => "FOO_BAR"
|
74 | stringcase.constcase('FOO_BAR'); // => "FOO_BAR"
|
75 | stringcase.constcase('fooBar'); // => "FOO_BAR"
|
76 | stringcase.constcase('FooBar'); // => "FOO_BAR"
|
77 |
|
78 |
|
79 | //------------------------
|
80 | // Convert to decapitalcase
|
81 | //------------------------
|
82 | stringcase.decapitalcase('foo_bar'); // => "foo_bar"
|
83 | stringcase.decapitalcase('FOO_BAR'); // => "fOO_BAR"
|
84 | stringcase.decapitalcase('fooBar'); // => "fooBar"
|
85 | stringcase.decapitalcase('FooBar'); // => "fooBar"
|
86 |
|
87 |
|
88 | //------------------------
|
89 | // Convert to lowercase
|
90 | //------------------------
|
91 | stringcase.lowercase('foo_bar'); // => "foo_bar"
|
92 | stringcase.lowercase('FOO_BAR'); // => "foo_bar"
|
93 | stringcase.lowercase('fooBar'); // => "foobar"
|
94 | stringcase.lowercase('FooBar'); // => "foobar"
|
95 |
|
96 |
|
97 | //------------------------
|
98 | // Convert to pascalcase
|
99 | //------------------------
|
100 | stringcase.pascalcase('foo_bar'); // => "FooBar"
|
101 | stringcase.pascalcase('FOO_BAR'); // => "FooBar"
|
102 | stringcase.pascalcase('fooBar'); // => "FooBar"
|
103 | stringcase.pascalcase('FooBar'); // => "FooBar"
|
104 |
|
105 |
|
106 | //------------------------
|
107 | // Convert to pathcase
|
108 | //------------------------
|
109 | stringcase.pathcase('foo_bar'); // => "foo/bar"
|
110 | stringcase.pathcase('FOO_BAR'); // => "foo/bar"
|
111 | stringcase.pathcase('fooBar'); // => "foo/bar"
|
112 | stringcase.pathcase('FooBar'); // => "foo/bar"
|
113 |
|
114 |
|
115 | //------------------------
|
116 | // Convert to sentencecase
|
117 | //------------------------
|
118 | stringcase.sentencecase('foo_bar'); // => "Foo bar"
|
119 | stringcase.sentencecase('FOO_BAR'); // => "Foo bar"
|
120 | stringcase.sentencecase('fooBar'); // => "Foo bar"
|
121 | stringcase.sentencecase('FooBar'); // => "Foo bar"
|
122 |
|
123 |
|
124 | //------------------------
|
125 | // Convert to snakecase
|
126 | //------------------------
|
127 | stringcase.snakecase('foo_bar'); // => "foo_bar"
|
128 | stringcase.snakecase('FOO_BAR'); // => "foo_bar"
|
129 | stringcase.snakecase('fooBar'); // => "foo_bar"
|
130 | stringcase.snakecase('FooBar'); // => "foo_bar"
|
131 |
|
132 |
|
133 | //------------------------
|
134 | // Convert to spinalcase
|
135 | //------------------------
|
136 | stringcase.spinalcase('foo_bar'); // => "foo-bar"
|
137 | stringcase.spinalcase('FOO_BAR'); // => "foo-bar"
|
138 | stringcase.spinalcase('fooBar'); // => "foo-bar"
|
139 | stringcase.spinalcase('FooBar'); // => "foo-bar"
|
140 |
|
141 |
|
142 | //------------------------
|
143 | // Convert to titlecase
|
144 | //------------------------
|
145 | stringcase.titlecase('foo_bar'); // => "Foo Bar"
|
146 | stringcase.titlecase('FOO_BAR'); // => "Foo Bar"
|
147 | stringcase.titlecase('fooBar'); // => "Foo Bar"
|
148 | stringcase.titlecase('FooBar'); // => "Foo Bar"
|
149 |
|
150 |
|
151 | //------------------------
|
152 | // Convert to trimcase
|
153 | //------------------------
|
154 | stringcase.trimcase('foo_bar'); // => "foo_bar"
|
155 | stringcase.trimcase('FOO_BAR'); // => "FOO_BAR"
|
156 | stringcase.trimcase('fooBar'); // => "fooBar"
|
157 | stringcase.trimcase('FooBar'); // => "FooBar"
|
158 |
|
159 |
|
160 | //------------------------
|
161 | // Convert to uppercase
|
162 | //------------------------
|
163 | stringcase.uppercase('foo_bar'); // => "FOO_BAR"
|
164 | stringcase.uppercase('FOO_BAR'); // => "FOO_BAR"
|
165 | stringcase.uppercase('fooBar'); // => "FOOBAR"
|
166 | stringcase.uppercase('FooBar'); // => "FOOBAR"
|
167 |
|
168 |
|
169 |
|
170 | ```
|
171 |
|
172 | Fore more detail, see [API Guide of stringcase functions](http://okunishinishi.github.io/node-stringcase/apiguide/module-stringcase_lib.html).
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 | <a name="license"></a>
|
181 |
|
182 | License
|
183 | -------
|
184 | This software is released under the [MIT License](https://github.com/okunishinishi/node-stringcase/blob/master/LICENSE).
|
185 |
|
186 |
|
187 |
|
188 |
|