string-character-is-astral-surrogate
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.1 • Public • Published

    string-character-is-astral-surrogate

    Tells, is given character a part of astral character, specifically, a high and low surrogate

    Install

    This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:

    npm i string-character-is-astral-surrogate

    If you need a legacy version which works with require, use version 1.13.0

    Quick Take

    import { strict as assert } from "assert";
    import {
      isHighSurrogate,
      isLowSurrogate,
    } from "string-character-is-astral-surrogate";
    
    // 🧢 = \uD83E\uDDE2
    
    assert.equal(isHighSurrogate("\uD83E"), true);
    // the first character, high surrogate of the cap is indeed a high surrogate
    
    assert.equal(isHighSurrogate("\uDDE2"), false);
    // the second character, low surrogate of the cap is NOT a high surrogate
    
    assert.equal(isLowSurrogate("\uD83E"), false);
    // the first character, high surrogate of the cap is NOT a low surrogate
    // it's a high surrogate
    
    assert.equal(isLowSurrogate("\uDDE2"), true);
    // the second character, low surrogate of the cap is indeed a low surrogate

    Documentation

    Please visit codsen.com for a full description of the API and examples.

    Contributing

    To report bugs or request features or assistance, raise an issue on GitHub.

    Licence

    MIT License

    Copyright (c) 2010-2021 Roy Revelt and other contributors

    ok codsen star

    Install

    npm i string-character-is-astral-surrogate

    DownloadsWeekly Downloads

    25,398

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    15.2 kB

    Total Files

    9

    Last publish

    Collaborators

    • royston