2.0.0 • Published 4 years ago

graphemes v2.0.0

Weekly downloads
46
License
MIT
Repository
github
Last release
4 years ago

Graphemes

A JavaScript library to convert a string into an array of graphemes, following the Unicode 12 Text Segmentation spec

aka Unicode® Standard Annex #29

  • Easy String -> String[] usage
  • Also handles streaming for huge text
    • Iterator of code points in
    • Iterator of graphemes out
  • Passes the Unicode 12 grapheme test suite
  • Straightforward, Modern Typescript implementation
  • Zero dependencies!

Usage

npm i graphemes

Example

const graphemes = require('graphemes');

const text = '각กำg̈';

console.log('Code points:', Array.from(text));
console.log('Graphemes:', graphemes.default(text));

/*
Code points: ['ᄀ', 'ᅡ', 'ᆨ','ก', 'ำ', 'g','̈']
Graphemes: [ '각', 'กำ', 'g̈' ]
*/