README.md (3752B)
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 # grapheme 22 23 > Grapheme cluster break tooling. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 </section> 30 31 <!-- /.intro --> 32 33 <!-- Package usage documentation. --> 34 35 <section class="usage"> 36 37 ## Usage 38 39 ```javascript 40 var grapheme = require( '@stdlib/string/tools/grapheme-cluster-break' ); 41 ``` 42 43 #### grapheme 44 45 A collection of functions for performing grapheme cluster break operations. 46 47 * * * 48 49 ### Methods 50 51 #### grapheme.breakProperty( code ) 52 53 Returns the grapheme break property from the [Unicode Standard][unicode-grapheme-break-property]. 54 55 ```javascript 56 var out = grapheme.breakProperty( 0x008f ); 57 // returns 2 58 59 out = grapheme.breakProperty( 0x111C2 ); 60 // returns 12 61 62 out = grapheme.breakProperty( 0x1F3FC ); 63 // returns 3 64 ``` 65 66 #### grapheme.emojiProperty( code ) 67 68 Returns the emoji property from the [Unicode Standard][unicode-emoji-property]. 69 70 ```javascript 71 var out = grapheme.emojiProperty( 0x23EC ); 72 // returns 101 73 74 out = grapheme.emojiProperty( 0x1FFFE ); 75 // returns 11 76 ``` 77 78 #### grapheme.breakType( breaks, emoji ) 79 80 Returns the break type between grapheme breaking classes according to _UAX #29 3.1.1 Grapheme Cluster Boundary Rules_ on extended grapheme clusters. 81 82 ```javascript 83 var out = grapheme.breakType( [ 11, 3, 11 ], [ 11, 11, 11 ] ); 84 // returns 1 85 ``` 86 87 * * * 88 89 ### Properties 90 91 #### grapheme.constants 92 93 An object mapping break type names to integer values. 94 95 ```javascript 96 var out = grapheme.constants; 97 // returns {...} 98 ``` 99 100 </section> 101 102 <!-- /.usage --> 103 104 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 105 106 <section class="notes"> 107 108 </section> 109 110 <!-- /.notes --> 111 112 <!-- Package usage examples. --> 113 114 <section class="examples"> 115 116 ## Examples 117 118 <!-- eslint no-undef: "error" --> 119 120 ```javascript 121 var grapheme = require( '@stdlib/string/tools/grapheme-cluster-break' ); 122 123 var out = grapheme.breakProperty( 0x008f ); 124 // returns 2 125 126 out = grapheme.emojiProperty( 0x23EC ); 127 // returns 101 128 129 out = grapheme.breakType( [ 11, 3, 11 ], [ 11, 11, 11 ] ); 130 // returns 1 131 132 out = grapheme.constants; 133 // returns {...} 134 ``` 135 136 </section> 137 138 <!-- /.examples --> 139 140 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 141 142 <section class="references"> 143 144 </section> 145 146 <!-- /.references --> 147 148 <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> 149 150 <section class="related"> 151 152 </section> 153 154 <!-- /.related --> 155 156 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 157 158 <section class="links"> 159 160 [unicode-grapheme-break-property]: https://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt 161 162 [unicode-emoji-property]: https://www.unicode.org/Public/13.0.0/ucd/emoji/emoji-data.txt 163 164 <!-- <related-links> --> 165 166 <!-- </related-links> --> 167 168 </section> 169 170 <!-- /.links -->