Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FlexIntType

Works like FlexUnsignedIntType, but allows for negative values as well. Less efficient for storing positive values than FlexUnsignedIntType, so use that instead if not storing negative values. Also limited to values between -(2 ** 52) and 2 ** 52 - 1. (Encodes value as approximately 2 * abs(value).)

Example:

let type = new sb.FlexIntType

Hierarchy

  • IntegerType<number | string, number>
    • FlexIntType

Index

Constructors

constructor

  • Returns FlexIntType

Accessors

Static _value

  • get _value(): number

Methods

addToBuffer

consumeValue

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

    • buffer: ArrayBuffer
    • offset: number

    Returns ReadResult<number>

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 FlexIntType
  • Determines whether the input is a Type with the same class

    Parameters

    • otherType: unknown

      A value, usually a Type instance

    Returns otherType is FlexIntType

    whether this and otherType are instances of the same Type class

readValue

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

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

    Returns number

toBuffer

  • toBuffer(): ArrayBuffer

valueBuffer

  • valueBuffer(value: string | number): ArrayBuffer
  • Parameters

    • value: string | number

    Returns ArrayBuffer

writeValue

  • Appends value bytes to an AppendableBuffer according to the type

    Example:

    //Takes 4 bytes
    type.writeValue(buffer, -2113664) //or '-2113664'
    
    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 | number

      The value to write

    Returns void

Generated using TypeDoc