https://github.com/denosaurs/byte_type
๐ A small helper module for working with different raw types in javascript
https://github.com/denosaurs/byte_type
abi browser deno encoding ffi raw-data struct typedarray typescript
Last synced: 5 months ago
JSON representation
๐ A small helper module for working with different raw types in javascript
- Host: GitHub
- URL: https://github.com/denosaurs/byte_type
- Owner: denosaurs
- License: mit
- Created: 2021-02-22T00:55:50.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-17T20:58:04.000Z (11 months ago)
- Last Synced: 2024-10-30T01:22:24.653Z (8 months ago)
- Topics: abi, browser, deno, encoding, ffi, raw-data, struct, typedarray, typescript
- Language: TypeScript
- Homepage: https://deno.land/x/byte_type
- Size: 91.8 KB
- Stars: 38
- Watchers: 4
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# byte_type
[](https://github.com/denosaurs/byte_type/releases)
[](https://github.com/denosaurs/byte_type/actions)
[](https://github.com/denosaurs/byte_type/blob/master/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
```ts
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
- Elias Sjรถgreen ([@eliassjogreen](https://github.com/eliassjogreen))
- Dean Srebnik ([@load1n9](https://github.com/load1n9))
- Skye ([@MierenManz](https://github.com/mierenmanz))### 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.