time-to-botec

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

README.md (2578B)


      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 # hasUTF16SurrogatePairAt
     22 
     23 > Test if a position in a string marks the start of a [UTF-16][utf-16] surrogate pair.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var hasUTF16SurrogatePairAt = require( '@stdlib/assert/has-utf16-surrogate-pair-at' );
     31 ```
     32 
     33 #### hasUTF16SurrogatePairAt( string, position )
     34 
     35 Tests if a `position` (in [UTF-16][utf-16] code units) in a `string` marks the start of a [UTF-16][utf-16] surrogate pair.
     36 
     37 ```javascript
     38 var bool = hasUTF16SurrogatePairAt( '🌷', 0 );
     39 // returns true
     40 
     41 bool = hasUTF16SurrogatePairAt( '🌷', 1 );
     42 // returns false
     43 ```
     44 
     45 </section>
     46 
     47 <!-- /.usage -->
     48 
     49 <section class="notes">
     50 
     51 ## Notes
     52 
     53 -   Note that `position` does **not** refer to a visual character position, but to an index in the ordered sequence of [UTF-16][utf-16] code units.
     54 
     55 </section>
     56 
     57 <!-- /.notes -->
     58 
     59 <section class="examples">
     60 
     61 ## Examples
     62 
     63 <!-- eslint no-undef: "error" -->
     64 
     65 ```javascript
     66 var hasUTF16SurrogatePairAt = require( '@stdlib/assert/has-utf16-surrogate-pair-at' );
     67 
     68 var bool = hasUTF16SurrogatePairAt( '🌷', 0 );
     69 // returns true
     70 
     71 bool = hasUTF16SurrogatePairAt( '🌷', 1 );
     72 // returns false
     73 
     74 ```
     75 
     76 </section>
     77 
     78 <!-- /.examples -->
     79 
     80 * * *
     81 
     82 <section class="cli">
     83 
     84 ## CLI
     85 
     86 <section class="usage">
     87 
     88 ### Usage
     89 
     90 ```text
     91 Usage: has-utf16-surrogate-pair-at [options] [<string>] --pos=<index>
     92 
     93 Options:
     94 
     95   -h,    --help                Print this message.
     96   -V,    --version             Print the package version.
     97          --pos index           Position in string.
     98 ```
     99 
    100 </section>
    101 
    102 <!-- /.usage -->
    103 
    104 <section class="examples">
    105 
    106 ### Examples
    107 
    108 ```bash
    109 $ has-utf16-surrogate-pair-at --pos=0 🌷
    110 true
    111 ```
    112 
    113 To use as a [standard stream][standard-streams],
    114 
    115 ```bash
    116 $ echo -n '🌷' | has-utf16-surrogate-pair-at --pos=1
    117 false
    118 ```
    119 
    120 </section>
    121 
    122 <!-- /.examples -->
    123 
    124 </section>
    125 
    126 <!-- /.cli -->
    127 
    128 <section class="links">
    129 
    130 [utf-16]: https://en.wikipedia.org/wiki/UTF-16
    131 
    132 [standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
    133 
    134 </section>
    135 
    136 <!-- /.links -->