imretro / bitio-ts

I/O with bits

Home Page:https://imretro.github.io/bitio-ts/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@imretro/bitio

npm CI codecov

I/O with bits

Examples

Reader

const { Reader } = require('@imretro/bitio');
const bytes = new Uint8Array([0xAB, 0xCD, 0xEF]);
const reader = new Reader(bytes);

console.log(reader.readBits(12)); // 2748 (0xABC)

Writer

const { Writer } = require('@imretro/bitio');
const dst = new Uint8Array(1);
const writer = new Writer(dst);
[1, 1, 1, 1, 0, 0, 0, 1].forEach((bit) => writer.writeBit(bit));

console.log(dst[0]); // 241 (0b11110001)

About

I/O with bits

https://imretro.github.io/bitio-ts/

License:MIT License


Languages

Language:TypeScript 96.5%Language:JavaScript 3.5%