@nevware21/ts-utils
    Preparing search index...

    Function polyStrAt

    • Polyfill implementation of String.prototype.at() that returns the character at the given integer index, supporting negative indices which count back from the end of the string.

      Delegates index normalisation and bounds checking to polyArrAt by treating the string as an array-like object, matching native String.prototype.at() behaviour exactly.

      Parameters

      • value: string

        The string value to retrieve a character from.

      • index: number

        The zero-based index of the character to return. Negative values count from the end: -1 is the last character, -2 is the second-to-last, and so on.

      Returns string

      A single-character string at the normalised index, or undefined if out of range.

      0.14.0

      TypeError if value is null or undefined.

      polyStrAt("hello", 0);   // "h"
      polyStrAt("hello", -1); // "o"
      polyStrAt("hello", -2); // "l"
      polyStrAt("hello", 99); // undefined
      polyStrAt("hello", -99); // undefined