README.md (4461B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2021 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # camelcase 22 23 > Convert a string to camel case. 24 25 <!-- Package usage documentation. --> 26 27 <section class="usage"> 28 29 ## Usage 30 31 ```javascript 32 var camelcase = require( '@stdlib/string/camelcase' ); 33 ``` 34 35 #### camelcase( str ) 36 37 Converts a string to camel case. 38 39 ```javascript 40 var out = camelcase( 'foo bar' ); 41 // returns 'fooBar' 42 43 out = camelcase( 'IS_MOBILE' ); 44 // returns 'isMobile' 45 46 out = camelcase( 'Hello World!' ); 47 // returns 'helloWorld' 48 49 out = camelcase( '--foo-bar--' ); 50 // returns 'fooBar' 51 ``` 52 53 </section> 54 55 <!-- /.usage --> 56 57 <!-- Package usage examples. --> 58 59 <section class="examples"> 60 61 ## Examples 62 63 ```javascript 64 var camelcase = require( '@stdlib/string/camelcase' ); 65 66 var str = 'Hello World!'; 67 var out = camelcase( str ); 68 // returns 'helloWorld' 69 70 str = 'HELLO WORLD!'; 71 out = camelcase( str ); 72 // returns 'helloWorld' 73 74 str = 'To be, or not to be: that is the question.'; 75 out = camelcase( str ); 76 // returns 'toBeOrNotToBeThatIsTheQuestion' 77 ``` 78 79 </section> 80 81 <!-- /.examples --> 82 83 * * * 84 85 <section class="cli"> 86 87 ## CLI 88 89 <section class="usage"> 90 91 ### Usage 92 93 ```text 94 Usage: camelcase [options] [<string>] 95 96 Options: 97 98 -h, --help Print this message. 99 -V, --version Print the package version. 100 --split sep Delimiter for stdin data. Default: '/\\r?\\n/'. 101 ``` 102 103 </section> 104 105 <!-- /.usage --> 106 107 <!-- CLI usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 108 109 <section class="notes"> 110 111 ### Notes 112 113 - If the split separator is a [regular expression][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes. 114 115 ```bash 116 # Not escaped... 117 $ echo -n $'beep\nfoo_bar' | camelcase --split /\r?\n/ 118 119 # Escaped... 120 $ echo -n $'beep\nfoo_bar' | camelcase --split /\\r?\\n/ 121 ``` 122 123 - The implementation ignores trailing delimiters. 124 125 </section> 126 127 <!-- /.notes --> 128 129 <section class="examples"> 130 131 ### Examples 132 133 ```bash 134 $ camelcase 'hello world!' 135 helloWorld 136 ``` 137 138 To use as a [standard stream][standard-streams], 139 140 ```bash 141 $ echo -n 'beEp booP' | camelcase 142 beEpBooP 143 ``` 144 145 By default, when used as a [standard stream][standard-streams], the implementation assumes newline-delimited data. To specify an alternative delimiter, set the `split` option. 146 147 ```bash 148 $ echo -n 'beep\nfoo_bar' | camelcase --split '\t' 149 beep 150 fooBar 151 ``` 152 153 </section> 154 155 <!-- /.examples --> 156 157 </section> 158 159 <!-- /.cli --> 160 161 <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> 162 163 <section class="related"> 164 165 * * * 166 167 ## See Also 168 169 - <span class="package-name">[`@stdlib/string/constantcase`][@stdlib/string/constantcase]</span><span class="delimiter">: </span><span class="description">convert a string to constant case.</span> 170 - <span class="package-name">[`@stdlib/string/kebabcase`][@stdlib/string/kebabcase]</span><span class="delimiter">: </span><span class="description">convert a string to kebab case.</span> 171 - <span class="package-name">[`@stdlib/string/snakecase`][@stdlib/string/snakecase]</span><span class="delimiter">: </span><span class="description">convert a string to snake case.</span> 172 173 </section> 174 175 <!-- /.related --> 176 177 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 178 179 <section class="links"> 180 181 [standard-streams]: https://en.wikipedia.org/wiki/Standard_streams 182 183 [mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions 184 185 <!-- <related-links> --> 186 187 [@stdlib/string/constantcase]: https://github.com/stdlib-js/string/tree/main/constantcase 188 189 [@stdlib/string/kebabcase]: https://github.com/stdlib-js/string/tree/main/kebabcase 190 191 [@stdlib/string/snakecase]: https://github.com/stdlib-js/string/tree/main/snakecase 192 193 <!-- </related-links> --> 194 195 </section> 196 197 <!-- /.links -->