/text-segmentation

A JavaScript library for Grapheme Breaking and identifying Grapheme Boundaries, implementing the Unicode Line Breaking Algorithm (UAX #29)

Primary LanguageTypeScriptMIT LicenseMIT

text-segmentation

CI NPM Downloads NPM Version

A JavaScript library for Grapheme Breaking and identifying Grapheme Boundaries, implementing the Unicode Line Breaking Algorithm (UAX #29)

Installing

You can install the module via npm:

npm install text-segmentation

Example

import {splitGraphemes} from 'text-segmentation';

const graphemes =  splitGraphemes('Hello ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ!');

Testing

You can run the test suite with:

npm test

The library implements all the GraphemeBreakTest.txt tests.