time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (5070B)


      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 # constantcase
     22 
     23 > Returns a string converted to a constant case.
     24 
     25 <!-- Package usage documentation. -->
     26 
     27 <section class="usage">
     28 
     29 ## Usage
     30 
     31 ```javascript
     32 var constantcase = require( '@stdlib/string/constantcase' );
     33 ```
     34 
     35 #### constantcase( str )
     36 
     37 Converts a string to constant case.
     38 
     39 ```javascript
     40 var str = constantcase( 'foo bar' );
     41 // returns 'FOO_BAR'
     42 
     43 str = constantcase( 'foo bar baz' );
     44 // returns 'FOO_BAR_BAZ'
     45 
     46 str = constantcase( 'foo_bar' );
     47 // returns 'FOO_BAR'
     48 ```
     49 
     50 </section>
     51 
     52 <!-- /.usage -->
     53 
     54 <!-- Package usage examples. -->
     55 
     56 <section class="examples">
     57 
     58 ## Examples
     59 
     60 ```javascript
     61 var constantcase = require( '@stdlib/string/constantcase' );
     62 
     63 var str = 'Hello World!';
     64 var out = constantcase( str );
     65 // returns 'HELLO_WORLD'
     66 
     67 str = 'I am a tiny little teapot';
     68 out = constantcase( str );
     69 // returns 'I_AM_A_TINY_LITTLE_TEAPOT'
     70 
     71 str = 'with big problems';
     72 out = constantcase( str );
     73 // returns 'WITH_BIG_PROBLEMS'
     74 
     75 str = 'To be, or not to be: that is the question.';
     76 out = constantcase( str );
     77 // returns 'TO_BE_OR_NOT_TO_BE_THAT_IS_THE_QUESTION'
     78 
     79 str = 'isMobile';
     80 out = constantcase( str );
     81 // returns 'IS_MOBILE'
     82 ```
     83 
     84 </section>
     85 
     86 <!-- /.examples -->
     87 
     88 * * *
     89 
     90 <section class="cli">
     91 
     92 ## CLI
     93 
     94 <section class="usage">
     95 
     96 ### Usage
     97 
     98 ```text
     99 Usage: constantcase [options] [<string>]
    100 
    101 Options:
    102 
    103   -h,    --help                Print this message.
    104   -V,    --version             Print the package version.
    105          --split sep           Delimiter for stdin data. Default: '/\\r?\\n/'.
    106 ```
    107 
    108 </section>
    109 
    110 <!-- /.usage -->
    111 
    112 <!-- CLI usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    113 
    114 <section class="notes">
    115 
    116 ### Notes
    117 
    118 -   If the split separator is a [regular expression][mdn-regexp], ensure that the `split` option is either properly escaped or enclosed in quotes.
    119 
    120     ```bash
    121     # Not escaped...
    122     $ echo -n $'beEp booP\nisMobile' | constantcase --split /\r?\n/
    123 
    124     # Escaped...
    125     $ echo -n $'beEp booP\nisMobile' | constantcase --split /\\r?\\n/
    126     ```
    127 
    128 -   The implementation ignores trailing delimiters.
    129 
    130 </section>
    131 
    132 <!-- /.notes -->
    133 
    134 <section class="examples">
    135 
    136 ### Examples
    137 
    138 ```bash
    139 $ constantcase 'hello world'
    140 HELLO_WORLD
    141 ```
    142 
    143 To use as a [standard stream][standard-streams],
    144 
    145 ```bash
    146 $ echo -n 'beEp booP' | constantcase
    147 BEEP_BOOP
    148 ```
    149 
    150 To use as a [standard stream][standard-streams],
    151 
    152 ```bash
    153 $ echo -n 'isMobile' | constantcase
    154 IS_MOBILE
    155 ```
    156 
    157 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.
    158 
    159 ```bash
    160 $ echo -n 'beep_boop\tisMobile' | constantcase --split '\t'
    161 BEEP_BOOP
    162 IS_MOBILE
    163 ```
    164 
    165 </section>
    166 
    167 <!-- /.examples -->
    168 
    169 </section>
    170 
    171 <!-- /.cli -->
    172 
    173 <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
    174 
    175 <section class="related">
    176 
    177 * * *
    178 
    179 ## See Also
    180 
    181 -   <span class="package-name">[`@stdlib/string/camelcase`][@stdlib/string/camelcase]</span><span class="delimiter">: </span><span class="description">convert a string to camel case.</span>
    182 -   <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>
    183 -   <span class="package-name">[`@stdlib/string/pascalcase`][@stdlib/string/pascalcase]</span><span class="delimiter">: </span><span class="description">convert a string to Pascal case.</span>
    184 -   <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>
    185 
    186 </section>
    187 
    188 <!-- /.related -->
    189 
    190 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    191 
    192 <section class="links">
    193 
    194 [standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
    195 
    196 [mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
    197 
    198 <!-- <related-links> -->
    199 
    200 [@stdlib/string/camelcase]: https://github.com/stdlib-js/string/tree/main/camelcase
    201 
    202 [@stdlib/string/kebabcase]: https://github.com/stdlib-js/string/tree/main/kebabcase
    203 
    204 [@stdlib/string/pascalcase]: https://github.com/stdlib-js/string/tree/main/pascalcase
    205 
    206 [@stdlib/string/snakecase]: https://github.com/stdlib-js/string/tree/main/snakecase
    207 
    208 <!-- </related-links> -->
    209 
    210 </section>
    211 
    212 <!-- /.links -->