Skip to main content

@denosaurs/byte-type@0.4.0

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

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
76%
Published
3 months ago

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 @denosaurs/byte-type

Import symbol

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

Add Package

npx jsr add @denosaurs/byte-type

Import symbol

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

Add Package

yarn dlx jsr add @denosaurs/byte-type

Import symbol

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

Add Package

pnpm dlx jsr add @denosaurs/byte-type

Import symbol

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

Add Package

bunx jsr add @denosaurs/byte-type

Import symbol

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