1.1.2 • Published 2 years ago

@genee/struct v1.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

struct

A C-like struct library for buffer parsing and packing

Usage

import { struct, int16_t, uint16_t, uint8_t, LE, UINT16_MAX, INT16_MIN } from '../../lib/struct';

const SENSOR = struct({
    manufacturer: uint16_t,
    version: uint8_t,
    modeAndModel: uint8_t,
    mac: uint8_t[6],
    temperature: LE(int16_t),
    humidity: LE(uint16_t),
    pressure: LE(int16_t),
    flag: uint8_t,
    gasType: uint8_t,
    gasValue: LE(int16_t),
    gasScale: uint8_t,
    adValue: LE(uint16_t),
    battery: uint8_t,
});

const parsed = SENSOR.parse(binaryData);

parsed.humidity = 16;
const newBuf = SENSOR.update({ version: 1 }).pack(parsed);
1.1.1

2 years ago

1.1.0

2 years ago

1.1.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago