node-ctypes - v2.17.1
    Preparing search index...

    Function readValue

    • Read a typed value from a buffer at a given offset.

      Type Parameters

      Parameters

      • ptr: MemorySource

        Buffer to read from

      • type: T

        Type to read (e.g. c_int32, c_double)

      • Optionaloffset: number

        Byte offset, a non-negative safe integer (default 0): a non-number is a TypeError, NaN, Infinity, a fraction or a negative value a RangeError

      Returns JsFromCType<T>

      const buf = Buffer.alloc(8);
      buf.writeInt32LE(42, 0);
      console.log(readValue(buf, c_int32)); // 42
    • Read a typed value from a buffer at a given offset.

      Parameters

      • ptr: MemorySource

        Buffer to read from

      • type: AnyType | StructureClass

        Type to read (e.g. c_int32, c_double)

      • Optionaloffset: number

        Byte offset, a non-negative safe integer (default 0): a non-number is a TypeError, NaN, Infinity, a fraction or a negative value a RangeError

      Returns any

      const buf = Buffer.alloc(8);
      buf.writeInt32LE(42, 0);
      console.log(readValue(buf, c_int32)); // 42