@marijn/find-cluster-break
Find the position of grapheme cluster breaks in a string
Last updated 3 months ago by marijn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @marijn/find-cluster-break 
SYNC missed versions from official npm registry.

@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.

Current Tags

  • 1.0.4                                ...           latest (3 months ago)

5 Versions

  • 1.0.4                                ...           3 months ago
  • 1.0.3                                ...           5 months ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
Maintainers (1)
Downloads
Total 18
Today 0
This Week 0
This Month 14
Last Day 0
Last Week 0
Last Month 4
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE