Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StringType

A type storing a string of UTF-8 characters, with no bound on length. Behavior is undefined if string contains \0 characters, and no errors will be thrown when writing an invalid string.

Example:

let type = new sb.StringType

Hierarchy

  • AbsoluteType<string>
    • StringType

Index

Constructors

constructor

  • Returns StringType

Accessors

Static _value

  • get _value(): number

Methods

addToBuffer

consumeValue

  • consumeValue(buffer: ArrayBuffer, offset: number): ReadResult<string>
  • Parameters

    • buffer: ArrayBuffer
    • offset: number

    Returns ReadResult<string>

equals

  • equals(otherType: unknown): boolean
  • Parameters

    • otherType: unknown

    Returns boolean

getHash

  • getHash(): string

getSignature

  • getSignature(): string

Private isBuffer

Private isSameType

  • isSameType(otherType: unknown): otherType is StringType
  • Determines whether the input is a Type with the same class

    Parameters

    • otherType: unknown

      A value, usually a Type instance

    Returns otherType is StringType

    whether this and otherType are instances of the same Type class

readValue

  • readValue(valueBuffer: ArrayBuffer | Uint8Array, offset?: number): string
  • Parameters

    • valueBuffer: ArrayBuffer | Uint8Array
    • offset: number = 0

    Returns string

toBuffer

  • toBuffer(): ArrayBuffer

valueBuffer

  • valueBuffer(value: string): ArrayBuffer
  • Parameters

    • value: string

    Returns ArrayBuffer

writeValue

  • Appends value bytes to an AppendableBuffer according to the type

    Example:

    type.writeValue(buffer, 'abcdéf')
    
    throws

    If the value doesn't match the type, e.g. new sb.StringType().writeValue(buffer, 23)

    Parameters

    • buffer: AppendableBuffer

      The buffer to which to append

    • value: string

      The value to write

    Returns void

Generated using TypeDoc