pamoja for TypeScript - v0.1.17
    Preparing search index...

    Class Quantizer

    Packs float readings to a fixed precision, for a link that charges per byte.

    const quantizer = new Quantizer(100) // keep two decimal places
    const packed = quantizer.encode([20.0, 20.1, 20.2])
    quantizer.decode(packed) // [20.0, 20.1, 20.2], to within 0.01
    Index
    • Creates a quantizer at the given precision.

      Parameters

      • scale: number

        The multiplier applied before rounding; 100 keeps two decimal places. Must be positive and finite.

      Returns Quantizer

      If the scale is not positive and finite.

    • Unpacks a batch, to within this quantizer's precision.

      Parameters

      • bytes: Uint8Array

        The encoding produced by encode at the same scale.

      Returns number[]

      The readings, in order.

      If the buffer is malformed.

    • Quantizes and packs a batch of readings.

      Parameters

      • readings: readonly number[]

        The readings, in order.

      Returns Buffer

      The packed encoding.