Helpers for implementing methods in StringRange and UnicodeType. They are provided publicly in case they can be useful for building other custom string-based types.
- Source
Methods
(static) compareLength(a, b) → {number}
Compare the length of two strings, using the count of unicode codepoints
Name | Type | Description |
---|---|---|
a | string | reference string |
b | string | string to compare with |
- Source
negative if a
has less; 0 if equal; positive if a
has more
- Type:
- number
(static) lastCodepoint(str) → {number}
Get the last codepoint of a string
Name | Type | Description |
---|---|---|
str | string | non-empty string to fetch the codepoint of |
- Source
the codepoint
- Type:
- number
(static) length(str) → {number}
Count number of unicode codepoints in a string, e.g. the UTF-32 encoded string length
Name | Type | Description |
---|---|---|
str | string | the string to get the length of |
- Source
the string length
- Type:
- number
(generator, static) pairwiseIterate(a, b) → {Array.<number>}
Pairwise iteration of the codepoints of two equal length strings
Name | Type | Description |
---|---|---|
a | string | first string |
b | string | second string |
- Source
tuple of codepoints [a, b]
- Type:
- Array.<number>
(static) utf16Length(codepoint) → {number}
Get the UTF-16 string length for a given codepoint
Name | Type | Description |
---|---|---|
codepoint | number | the unicode codepoint |
- Source
two if its a surrogate pair, else one
- Type:
- number