Skip to content

Commit

Permalink
fix: Update the README to match the new API (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
irbull authored Jan 16, 2024
1 parent f76d1a4 commit d7bb332
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2023 the denosaurs team
Copyright (c) 2021-2024 the denosaurs team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,23 @@ native js performance and ergonomic interfaces!
## Usage

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

const o = new PackedStruct({ "b": u8, "a": u32 }).view(
new DataView(new ArrayBuffer(5)),
0,
);
const buffer = new ArrayBuffer(8);
const dt = new DataView(buffer);

console.log(o.valueOf());
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
Expand All @@ -33,4 +42,4 @@ Pull request, issues and feedback are very welcome. Code style is formatted with

### Licence

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

0 comments on commit d7bb332

Please sign in to comment.