Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

split-graphemes

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

split-graphemes

Divide the string into graphemes.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
increased by17.3%
Maintainers
1
Weekly downloads
 
Created
Source

split-graphemes

Divide ligature letters, such as Thai, Khmer letters and some emoji, that deform or combine glyphs depending on the position of characters into the minimum unit parts, graphemes.

It can also be used for strings containing characters other than ligatures, like alphabets and Japanese.

CircleCI

Installation

$ npm install split-graphemes

Usage

Use splitGraphemes(str) instead of Array.from(str) to separate character strings into character units.

Examples

Emoji

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

Khmer characters

// It is interpreted as 8 characters.
const chars = Array.from('ប៉ុស្ដិ៍') // ['ប', '៉', 'ុ', 'ស', '្', 'ដ', 'ិ', '៍']
const chars = splitGraphemes('ប៉ុស្ដិ៍') // ['ប៉ុស្ដិ៍']

Supported ligature characters

The list of characters is at here.

Keywords

FAQs

Package last updated on 18 Dec 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc