Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StringBuffer

AbstractCharBuffer implementation using a single {@link String}.

Hierarchy

Index

Constructors

constructor

Properties

Private _buffer

_buffer: string

Protected _length

_length: number

Accessors

length

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

Static isSupported

  • get isSupported(): boolean

Methods

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
  • Write a charCode to the buffer using {@link String#fromCharCode} and {@link String#concat +}.

    Parameters

    • charCode: number
    • Optional offset: undefined | number

    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

Static fromString

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

Generated using TypeDoc