Options
All
  • Public
  • Public/Protected
  • All
Menu

AbstractCharBuffer implementation using a [Typed Array][1] (more precisely an [Uint16Array][2]).

Hierarchy

Index

Constructors

constructor

Properties

Private _buffer

_buffer: Uint16Array

Protected _length

_length: number

Accessors

length

  • get length(): number
  • set length(newLength: number): void

Static isSupported

  • get isSupported(): boolean

Methods

Protected _ensureCapacity

  • _ensureCapacity(minCapacity: number): void
  • Ensures a minimum capacity.

    Parameters

    • minCapacity: number

      The minimum capacity (i.e. the expected {@link String#length length} of the {@link String} this buffer may represent).

    Returns void

append

  • append(charCode: number): this

charAt

  • charAt(offset: number): string

charCodeAt

  • charCodeAt(offset: number): number

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

Protected setLength

  • setLength(newLength: number): void

toString

  • toString(): string

write

  • write(charCode: number, offset?: undefined | number): 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

Static fromString

  • fromString(string: string, transform?: undefined | function, thisArg?: any): TypedArrayBuffer

Generated using TypeDoc