Socket
Book a DemoInstallSign in
Socket

@broofa/stringlang

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@broofa/stringlang

Utility functions for analyzing strings by Unicode block

latest
Source
npmnpm
Version
3.0.0
Version published
Maintainers
1
Created
Source

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
// ]

Keywords

unicode

FAQs

Package last updated on 29 Nov 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