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

grapheme-splitter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grapheme-splitter

A JavaScript library that breaks strings into their individual user-perceived characters. It supports emojis!

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.3M
increased by8.27%
Maintainers
1
Weekly downloads
 
Created

What is grapheme-splitter?

The grapheme-splitter npm package is designed to split strings into their constituent graphemes according to the Unicode Standard. This is particularly useful for accurately counting characters, especially in languages or scripts where a single visual character (grapheme cluster) may be composed of multiple Unicode characters. It helps in handling strings in a way that is more aligned with user expectations across different languages and scripts.

What are grapheme-splitter's main functionalities?

Splitting strings into graphemes

This feature allows you to split a string into an array of its constituent graphemes. The code sample demonstrates splitting a complex emoji (which is a single grapheme cluster composed of multiple Unicode characters) into its individual graphemes.

"use strict";\nconst GraphemeSplitter = require('grapheme-splitter');\nconst splitter = new GraphemeSplitter();\nconsole.log(splitter.splitGraphemes('👩‍❤️‍💋‍👩'));

Counting graphemes in a string

This feature provides the ability to count the number of graphemes in a string, which can be more accurate than counting code points or bytes, especially for strings containing complex characters or emojis. The code sample demonstrates counting the number of graphemes in a string that visually appears as a single character.

"use strict";\nconst GraphemeSplitter = require('grapheme-splitter');\nconst splitter = new GraphemeSplitter();\nconsole.log(splitter.countGraphemes('👩‍❤️‍💋‍👩'));

Other packages similar to grapheme-splitter

Keywords

FAQs

Package last updated on 11 Sep 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