Skip to main content

Built and signed on GitHub Actions

😋 A small helper module for working with different raw (byte) types in javascript

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
76%
Published
2 months ago (0.4.1)

byte_type

Tags Checks License

byte_type is a small helper module for efficiently working with different raw types represented as a bunch of bytes. Now with performance being close to native js performance and ergonomic interfaces!

Usage

import { Struct, u32, u8 } from "https://deno.land/x/byte_type/mod.ts";

const buffer = new ArrayBuffer(8);
const dt = new DataView(buffer);

const struct = new Struct({ "b": u8, "a": u32 });

struct.write({ b: 8, a: 32 }, dt);
console.log(struct.read(dt));
console.log(buffer);

// Output:
// { b: 8, a: 32 }
// ArrayBuffer {
//   [Uint8Contents]: <08 00 00 00 20 00 00 00>,
//   byteLength: 8
// }

Maintainers

Contribution

Pull request, issues and feedback are very welcome. Code style is formatted with deno fmt and commit messages are done following Conventional Commits spec.

Licence

Copyright 2021-2024, the denosaurs team. All rights reserved. MIT license.

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add jsr:@denosaurs/byte-type

Import symbol

import * as byte_type from "@denosaurs/byte-type";

---- OR ----

Import directly with a jsr specifier

import * as byte_type from "jsr:@denosaurs/byte-type";

Add Package

npx jsr add @denosaurs/byte-type

Import symbol

import * as byte_type from "@denosaurs/byte-type";

Add Package

yarn dlx jsr add @denosaurs/byte-type

Import symbol

import * as byte_type from "@denosaurs/byte-type";

Add Package

pnpm dlx jsr add @denosaurs/byte-type

Import symbol

import * as byte_type from "@denosaurs/byte-type";

Add Package

bunx jsr add @denosaurs/byte-type

Import symbol

import * as byte_type from "@denosaurs/byte-type";