Options
All
  • Public
  • Public/Protected
  • All
Menu

Base class for all CharBuffers.

Hierarchy

Index

Constructors

Protected constructor

Properties

Protected _length

_length: number

Accessors

length

  • get length(): number
  • set length(newLength: number): void
  • Length of the {@link String} represented by this buffer.

    Returns number

  • Sets the length of the {@link String} represented by this buffer.

    throws

    {RangeError} if newLength < 0 || newLength > this.length

    Parameters

    • newLength: number

      The new length.

    Returns void

Static isSupported

  • get isSupported(): boolean

Methods

append

  • append(charCode: number): this
  • Appends a charCode to the buffer. The length of the buffer increases by 1.

    Parameters

    • charCode: number

      The charCode to append.

    Returns this

Abstract charAt

  • charAt(offset: number): string
  • Reads the char at an offset.

    throws

    {Error} if offset < 0 or offset >= this.length

    Parameters

    • offset: number

      The zero based offset.

    Returns string

    The char.

Abstract charCodeAt

  • charCodeAt(offset: number): number
  • Reads the charCode at an offset.

    throws

    if offset < 0 or offset >= this.length

    Parameters

    • offset: number

      The zero based offset.

    Returns number

    The charCode.

Protected clone

  • clone(): this

forEach

  • forEach(callback: function, thisArg?: any): void
  • Executes a function once per charCode. See also {@link Array#forEach}

    Parameters

    • callback: function

      Function to execute for each charCode.

        • (value: number, index: number, buffer: this): void
        • Parameters

          • value: number
          • index: number
          • buffer: this

          Returns void

    • Optional thisArg: any

      Value to use as this when executing callback.

    Returns void

map

  • map(callback: function, thisArg?: any): this
  • Creates a new CharBuffer with the results of calling a provided function on every charCode. See also {@link Array#map}

    Parameters

    • callback: function

      Function to execute for each charCode.

        • (value: number, index: number, buffer: this): number
        • Parameters

          • value: number
          • index: number
          • buffer: this

          Returns number

    • Optional thisArg: any

      Value to use as this when executing callback.

    Returns this

read

  • read(offset: number): number
  • Reads the charCode at an offset.

    throws

    if offset < 0 or offset >= this.length

    Parameters

    • offset: number

      The zero based offset.

    Returns number

    The charCode.

Protected setLength

  • setLength(newLength: number): void

Abstract toString

  • toString(): string

Abstract write

  • write(charCode: number, offset?: undefined | number): this
  • Writes a charCode to the buffer at an offset.

    throws

    if offset < 0 or offset > this.length

    Parameters

    • charCode: number

      charCode The charCode to write.

    • Optional offset: undefined | number

      offset The zero based offset to write at.

    Returns this

Static Protected _fromString

  • _fromString<T>(output: T, string: string, transform?: undefined | function, thisArg?: any): T
  • Creates a new CharBuffer from a {@link String}.

    Type parameters

    Parameters

    • output: T
    • string: string

      The string.

    • Optional transform: undefined | function

      Function that produces a charCode for the new CharBuffer from a charCode of the string parameter.

    • Optional thisArg: any
      var charBuffer;
      
      charBuffer = CharBuffer.fromString('abc');
      console.log(charBuffer.toString()); // output: abc
      
      charBuffer = CharBuffer.fromString('abc', function (charCode, index){
          return charCode + 3;
      });
      
      console.log(charBuffer.toString()); // output: def

    Returns T

Generated using TypeDoc