Socket
Socket
Sign inDemoInstall

split-graphemes

Package Overview
Dependencies
0
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    split-graphemes

Divide the string into graphemes.


Version published
Maintainers
2
Install size
14.0 kB
Created

Readme

Source

split-graphemes

Divide ligature letters such as Thai, Khmer letters and complex emoji into array of graphemes. You can simply use this library instead of Array.from to get graphemes.

CircleCI

Installation

$ npm install split-graphemes

Examples

Emoji

// An emoji '👨‍👩‍👦‍👦' consists of 4 people face emoji joined by Zero Width Joiners (ZWJ).
const chars = Array.from('👨‍👩‍👦‍👦') // ['👨', ZWJ, '👩', ZWJ, '👦', ZWJ, '👦']
// It is interpreted exactly as one character!
const chars = splitGraphemes('👨‍👩‍👦‍👦') // ['👨‍👩‍👦‍👦']

Khmer characters

Array.from('ប៉ុស្ដិ៍') // ['ប', '៉', 'ុ', 'ស', '្', 'ដ', 'ិ', '៍']
splitGraphemes('ប៉ុស្ដិ៍') // ['ប៉ុ', 'ស្ដិ៍']

Japanese NFD

splitGraphemes('ごん゙に゙ぢば') // ['ご', 'ん゙', 'に゙', 'ぢ', 'ば']
splitGraphemes('パピプペポ') // ['パ', 'ピ', 'プ', 'ペ', 'ポ']

English

splitGraphemes('Hello') // ['H', 'e', 'l', 'l', 'o']

Supported ligature characters

The list of characters is at here.

Keywords

FAQs

Last updated on 27 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc