time-to-botec

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

README.md (3245B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2020 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 # numGraphemeClusters
     22 
     23 > Return the number of [grapheme clusters][unicode-text-segmentation] in a string.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var numGraphemeClusters = require( '@stdlib/string/num-grapheme-clusters' );
     31 ```
     32 
     33 #### numGraphemeClusters( str )
     34 
     35 Returns the number of [grapheme clusters][unicode-text-segmentation] in a `string`.
     36 
     37 ```javascript
     38 var out = numGraphemeClusters( 'last man standing' );
     39 // returns 17
     40 
     41 out = numGraphemeClusters( 'Hidden Treasures' );
     42 // returns 16
     43 ```
     44 
     45 </section>
     46 
     47 <!-- /.usage -->
     48 
     49 <section class="examples">
     50 
     51 ## Examples
     52 
     53 <!-- eslint no-undef: "error" -->
     54 
     55 ```javascript
     56 var numGraphemeClusters = require( '@stdlib/string/num-grapheme-clusters' );
     57 
     58 var str = numGraphemeClusters( 'last man standing' );
     59 // returns 17
     60 
     61 str = numGraphemeClusters( '六书/六書' );
     62 // returns 5
     63 
     64 str = numGraphemeClusters( 'अनुच्छेद' );
     65 // returns 5
     66 
     67 str = numGraphemeClusters( '🌷' );
     68 // returns 1
     69 ```
     70 
     71 </section>
     72 
     73 <!-- /.examples -->
     74 
     75 * * *
     76 
     77 <section class="cli">
     78 
     79 ## CLI
     80 
     81 <section class="usage">
     82 
     83 ### Usage
     84 
     85 ```text
     86 Usage: num-grapheme-clusters [options] [<string>]
     87 
     88 Options:
     89 
     90   -h,    --help                Print this message.
     91   -V,    --version             Print the package version.
     92   -l,    --lines               Analyze individual lines.
     93 ```
     94 
     95 </section>
     96 
     97 <!-- /.usage -->
     98 
     99 <section class="examples">
    100 
    101 ### Examples
    102 
    103 ```bash
    104 $ num-grapheme-clusters beep
    105 4
    106 ```
    107 
    108 To use as a [standard stream][standard-streams],
    109 
    110 ```bash
    111 $ echo -n 'beep\nboop🌷' | num-grapheme-clusters
    112 10
    113 ```
    114 
    115 ```bash
    116 $ echo -n 'beep\nboop🌷' | num-grapheme-clusters -l
    117 4
    118 5
    119 ```
    120 
    121 </section>
    122 
    123 <!-- /.examples -->
    124 
    125 </section>
    126 
    127 <!-- /.cli -->
    128 
    129 <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
    130 
    131 <section class="related">
    132 
    133 * * *
    134 
    135 ## See Also
    136 
    137 -   <span class="package-name">[`@stdlib/string/next-grapheme-cluster-break`][@stdlib/string/next-grapheme-cluster-break]</span><span class="delimiter">: </span><span class="description">return the next extended grapheme cluster break in a string after a specified position.</span>
    138 
    139 </section>
    140 
    141 <!-- /.related -->
    142 
    143 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    144 
    145 <section class="links">
    146 
    147 [unicode-text-segmentation]: http://www.unicode.org/reports/tr29/
    148 
    149 [standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
    150 
    151 <!-- <related-links> -->
    152 
    153 [@stdlib/string/next-grapheme-cluster-break]: https://github.com/stdlib-js/string/tree/main/next-grapheme-cluster-break
    154 
    155 <!-- </related-links> -->
    156 
    157 </section>
    158 
    159 <!-- /.links -->