vael:chars
Unicode scalar character classification and single-code-point case conversion predicates.
Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite) runtimes.
All classification predicates are total and never throw.
import ... from "vael:chars"
vael-chars (enabled by default in vaeljs-core and vaeljs-lite-core)Example
Section titled “Example”import { isDigit, isLetter, isSpace, toLower, toUpper } from "vael:chars";
console.log(isLetter("A".codePointAt(0))); // trueconsole.log(isDigit("7".codePointAt(0))); // trueconsole.log(isSpace(" ".codePointAt(0))); // trueconsole.log(String.fromCodePoint(toUpper(0x61), toLower(0x5a))); // "Az"isCharv0.0.0-alpha.0true if value is a Unicode scalar value (integer in 0..=0x10FFFF excluding UTF-16 surrogates 0xD800..=0xDFFF).isAsciiv0.0.0-alpha.0true if value is an ASCII scalar value (0..=0x7F). Total predicate.isLatin1v0.0.0-alpha.0true if value is a Latin-1 scalar value (0..=0xFF). Total predicate.isControlv0.0.0-alpha.0true if value is a Unicode control character (category Cc). Total predicate.isDigitv0.0.0-alpha.0true if value is a decimal digit (Unicode category Nd). Total predicate.isLetterv0.0.0-alpha.0true if value is a Unicode letter (category L: Lu | Ll | Lt | Lm | Lo). Total predicate.isLetterOrDigitv0.0.0-alpha.0true if value is a Unicode letter (L) or decimal digit (Nd). Total predicate.isLowerv0.0.0-alpha.0true if value is a lowercase letter (Unicode category Ll). Total predicate.isUpperv0.0.0-alpha.0true if value is an uppercase letter (Unicode category Lu). Total predicate.isPuncv0.0.0-alpha.0true if value is Unicode punctuation (category P). Total predicate.isSpacev0.0.0-alpha.0true if value is whitespace (\t, \n, \v, \f, \r, space, U+0085, or Unicode categories Zs, Zl, Zp).isSymbolv0.0.0-alpha.0true if value is a Unicode symbol (category S, including emoji). Total predicate.toLowerv0.0.0-alpha.0toUpperv0.0.0-alpha.0Functions
Section titled “Functions”isChar
Section titled “isChar”export function isChar(value: unknown): boolean;
Return true if value is a Unicode scalar value (integer in 0..=0x10FFFF
excluding UTF-16 surrogates 0xD800..=0xDFFF).
Total predicate: non-numbers, NaN, infinities, fractions, and out-of-range
values return false.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a valid Unicode scalar code point.import { isChar } from "vael:chars";
console.log(isChar(0x1f680)); // trueconsole.log(isChar(0xd800)); // false (surrogate)isAscii
Section titled “isAscii”export function isAscii(value: unknown): boolean;
Return true if value is an ASCII scalar value (0..=0x7F). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is an integer in 0..=0x7F.isLatin1
Section titled “isLatin1”export function isLatin1(value: unknown): boolean;
Return true if value is a Latin-1 scalar value (0..=0xFF). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is an integer in 0..=0xFF.isControl
Section titled “isControl”export function isControl(value: unknown): boolean;
Return true if value is a Unicode control character (category Cc). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a Unicode control scalar.isDigit
Section titled “isDigit”export function isDigit(value: unknown): boolean;
Return true if value is a decimal digit (Unicode category Nd). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a Unicode decimal digit scalar.isLetter
Section titled “isLetter”export function isLetter(value: unknown): boolean;
Return true if value is a Unicode letter (category L: Lu | Ll | Lt | Lm | Lo). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a Unicode letter scalar.isLetterOrDigit
Section titled “isLetterOrDigit”export function isLetterOrDigit(value: unknown): boolean;
Return true if value is a Unicode letter (L) or decimal digit (Nd). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a Unicode letter or decimal digit scalar.isLower
Section titled “isLower”export function isLower(value: unknown): boolean;
Return true if value is a lowercase letter (Unicode category Ll). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a Unicode lowercase letter scalar.isUpper
Section titled “isUpper”export function isUpper(value: unknown): boolean;
Return true if value is an uppercase letter (Unicode category Lu). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a Unicode uppercase letter scalar.isPunc
Section titled “isPunc”export function isPunc(value: unknown): boolean;
Return true if value is Unicode punctuation (category P). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a Unicode punctuation scalar.isSpace
Section titled “isSpace”export function isSpace(value: unknown): boolean;
Return true if value is whitespace (\t, \n, \v, \f, \r, space,
U+0085, or Unicode categories Zs, Zl, Zp).
Follows Go unicode.IsSpace semantics: U+FEFF and U+200B return false.
Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a Unicode whitespace scalar.isSymbol
Section titled “isSymbol”export function isSymbol(value: unknown): boolean;
Return true if value is a Unicode symbol (category S, including emoji). Total predicate.
| Name | Type | Description |
|---|---|---|
value | unknown | Candidate value to test. |
boolean — true when value is a Unicode symbol scalar.toLower
Section titled “toLower”export function toLower(value: number): number;
Map a Unicode scalar value to its single-code-point lowercase equivalent.
Multi-code-point expansions leave the scalar unchanged.
| Name | Type | Description |
|---|---|---|
value | number | Unicode scalar value (0..=0x10FFFF, excluding surrogates). |
number — Lowercase Unicode scalar code point.TypeError— whenvalueis not a number.RangeError— whenvalueis not a Unicode scalar value.
import { toLower } from "vael:chars";
console.log(String.fromCodePoint(toLower(0x41))); // "a"toUpper
Section titled “toUpper”export function toUpper(value: number): number;
Map a Unicode scalar value to its single-code-point uppercase equivalent.
Multi-code-point expansions such as U+00DF (ß) leave the scalar unchanged.
| Name | Type | Description |
|---|---|---|
value | number | Unicode scalar value (0..=0x10FFFF, excluding surrogates). |
number — Uppercase Unicode scalar code point.TypeError— whenvalueis not a number.RangeError— whenvalueis not a Unicode scalar value.
import { toUpper } from "vael:chars";
console.log(String.fromCodePoint(toUpper(0x61))); // "A"