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

@marijn/find-cluster-break

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marijn/find-cluster-break

Find the position of grapheme cluster breaks in a string

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
246K
increased by876875%
Maintainers
1
Weekly downloads
 
Created
Source

@marijn/find-cluster-break

Small JavaScript module for finding grapheme cluster breaks in strings, scanning from a given position.

import {findClusterBreak} from "@marijn/find-cluster-break"
console.log(findClusterBreak("💪🏽🦋", 0))
// → 4

This code is open source, released under an MIT license.

Documentation

findClusterBreak(str: string, pos: number, forward = true, includeExtending = true): number

Returns a next grapheme cluster break after (not equal to) pos, if forward is true, or before otherwise. Returns pos itself if no further cluster break is available in the string. Moves across surrogate pairs, extending characters (when includeExtending is true, which is the default), characters joined with zero-width joiners, and flag emoji.

isExtendingChar(code: number): boolean

Query whether the given character has a Grapheme_Cluster_Break value of Extend in Unicode.

Keywords

FAQs

Package last updated on 09 Dec 2024

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