npm.io
2.4.1 • Published 6d ago

@yozora/character

Licence
MIT
Version
2.4.1
Deps
0
Size
810 kB
Vulns
0
Weekly
0
Stars
157

@yozora/character


Character primitives used by Yozora tokenizers: code-point constants, character predicates, source-position tracking, entity references, and Unicode case folding.

Install

npm install --save @yozora/character

Usage

import {
  createNodePointGenerator,
  foldCase,
  isPunctuationCharacter,
} from '@yozora/character'

const points = [...createNodePointGenerator('Hello, 世界')]
const identifier = foldCase('Yozora')
const commaIsPunctuation = isPunctuationCharacter(','.codePointAt(0)!)

Key exports include:

  • AsciiCodePoint, Unicode category enums, and VirtualCodePoint
  • ASCII/Unicode whitespace, punctuation, control, digit, and letter predicates
  • createNodePointGenerator and helpers for reading text from node-point intervals
  • named and numeric entity-reference parsing
  • foldCase, stripChineseCharacters, and tightenChineseCharacters