Installation
Quick Take
Idea
This program identifies high and low surrogates, specifically.
In theory, high surrogate goes first, low surrogate goes second (source). This program enables us to detect surrogate-related errors, for example, malformed emoji or parts of emoji.
API
Two functions, same API:
Input: zero or more characters, where charCodeAt(0)
will be evaluated.
Output: A boolean
- If input is empty string or undefined,
false
is returned. - If input is anything other than the string or undefined, type error is thrown.
- If input consists of more characters, everything beyond
.charCodeAt(0)
is ignored.
We return false to make life easier when traversing the string. When you check “next” character, if it doesn’t exist, as far as astral-ness is concerned, we’re fine, so it yields false
. Otherwise, you’d have to check the input before feeding into this library and that’s is tedious. This is a low-level library and it doesn’t have to be picky.