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

graphemer

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphemer

A JavaScript library that breaks strings into their individual user-perceived characters (including emojis!)

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is graphemer?

The graphemer npm package is designed to handle and manipulate strings in a way that is aware of grapheme clusters, which are the visually recognizable characters, taking into account complex script behaviors and emoji sequences. This is particularly useful for applications that need to correctly count, split, or iterate over characters in strings that include multi-byte characters, emoji, and other composite characters that standard JavaScript string methods may not handle correctly.

What are graphemer's main functionalities?

Splitting strings into grapheme clusters

This feature allows you to split a string into an array of its constituent grapheme clusters, which is especially useful for strings containing emojis or characters from complex scripts.

const Graphemer = require('graphemer').default;
const splitter = new Graphemer();
const clusters = splitter.splitGraphemes('👋🏽 World');
console.log(clusters);

Counting grapheme clusters in a string

This feature provides the ability to count the number of grapheme clusters in a string, offering a more accurate character count for strings that include complex characters.

const Graphemer = require('graphemer').default;
const splitter = new Graphemer();
const count = splitter.countGraphemes('👋🏽 World');
console.log(count);

Iterating over grapheme clusters in a string

This feature enables iteration over each grapheme cluster in a string, allowing for operations to be performed on each visual character unit.

const Graphemer = require('graphemer').default;
const splitter = new Graphemer();
for (const cluster of splitter.iterateGraphemes('👋🏽 World')) {
  console.log(cluster);
}

Other packages similar to graphemer

Keywords

FAQs

Package last updated on 19 Sep 2022

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