3.0.0 • Published 1 year ago

@broofa/stringlang v3.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
1 year ago

stringlang

Utility functions for analyzing strings by Unicode block

Installation

npm i @broofa/stringlang
import {unicodeBlock, unicodeBlockCount, BLOCKS} from 'stringlang';

unicodeBlock()

Get block of a given character or code point.

Note: Runs at 10M+ chars/second on a modern Mac laptop (test data)

// Get block (codePoint)
unicodeBlock(30028); // => 'CJK Unified Ideographs'
// Get block (string)
unicodeBlock('界'); // => 'CJK Unified Ideographs'
// Get block (string, character index)
unicodeBlock('Aα界', 2); // => 'CJK Unified Ideographs'

unicodeBlockCount()

Count characters by block

unicodeBlockCount('Hello World or Καλημέρα κόσμε or こんにちは 世界'); // =>
// {
//   'Basic Latin': 21,
//   'CJK Unified Ideographs': 2,
//   'Greek and Coptic': 13,
//   Hiragana: 5
// }

BLOCKS

Array of block name, min code point, max code point entries, ordered by code point.

BLOCKS; // =>
// [
//   [ 'Basic Latin', 0, 127 ],
//   [ 'Latin-1 Supplement', 128, 255 ],
//   ... 308 more entries
// ]
2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

1 year ago

2.0.4

1 year ago

3.0.0

1 year ago

1.0.3

5 years ago

1.0.0

6 years ago