Natural Pleistocene Monsters

    @stdlib/assert-has-utf16-surrogate-pair-at
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.8 • Public • Published

    hasUTF16SurrogatePairAt

    NPM version Build Status Coverage Status

    Test if a position in a string marks the start of a UTF-16 surrogate pair.

    Installation

    npm install @stdlib/assert-has-utf16-surrogate-pair-at

    Usage

    var hasUTF16SurrogatePairAt = require( '@stdlib/assert-has-utf16-surrogate-pair-at' );

    hasUTF16SurrogatePairAt( string, position )

    Tests if a position (in UTF-16 code units) in a string marks the start of a UTF-16 surrogate pair.

    var bool = hasUTF16SurrogatePairAt( '🌷', 0 );
    // returns true
    
    bool = hasUTF16SurrogatePairAt( '🌷', 1 );
    // returns false

    Notes

    • Note that position does not refer to a visual character position, but to an index in the ordered sequence of UTF-16 code units.

    Examples

    var hasUTF16SurrogatePairAt = require( '@stdlib/assert-has-utf16-surrogate-pair-at' );
    
    var bool = hasUTF16SurrogatePairAt( '🌷', 0 );
    // returns true
    
    bool = hasUTF16SurrogatePairAt( '🌷', 1 );
    // returns false

    CLI

    Installation

    To use the module as a general utility, install the module globally

    npm install -g @stdlib/assert-has-utf16-surrogate-pair-at

    Usage

    Usage: has-utf16-surrogate-pair-at [options] [<string>] --pos=<index>
    
    Options:
    
      -h,    --help                Print this message.
      -V,    --version             Print the package version.
             --pos index           Position in string.
    

    Examples

    $ has-utf16-surrogate-pair-at --pos=0 🌷
    true

    To use as a standard stream,

    $ echo -n '🌷' | has-utf16-surrogate-pair-at --pos=1
    false

    Notice

    This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

    For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

    Community

    Chat


    License

    See LICENSE.

    Copyright

    Copyright © 2016-2022. The Stdlib Authors.

    Install

    npm i @stdlib/assert-has-utf16-surrogate-pair-at

    Homepage

    stdlib.io

    DownloadsWeekly Downloads

    484

    Version

    0.0.8

    License

    Apache-2.0

    Unpacked Size

    41.7 kB

    Total Files

    12

    Last publish

    Collaborators

    • stdlib-bot
    • kgryte
    • planeshifter
    • rreusser