binary-util
Advanced tools
Comparing version 0.0.0 to 1.0.0
{ | ||
"name": "binary-util", | ||
"description": "A utility library for working with binary data.", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"version": "1.0.0", | ||
"author": "BeeeQueue <adam@haglund.dev>", | ||
"repository": { | ||
"type": "github", | ||
"url": "https://github.com/beeequeue/binary-util" | ||
}, | ||
"license": "MIT", | ||
@@ -34,2 +39,4 @@ "engines": { | ||
"@antfu/eslint-config": "3.0.0", | ||
"@changesets/changelog-github": "0.5.0", | ||
"@changesets/cli": "2.27.7", | ||
"@tsconfig/node22": "22.0.0", | ||
@@ -41,2 +48,3 @@ "@tsconfig/strictest": "2.0.5", | ||
"prettier": "3.3.3", | ||
"publint": "0.2.10", | ||
"simple-git-hooks": "2.11.1", | ||
@@ -43,0 +51,0 @@ "tsup": "8.2.4", |
# binary-util | ||
<!-- | ||
[![npm](https://img.shields.io/npm/v/binary-util)](https://www.npmjs.com/package/binary-util) | ||
![npm bundle size](https://img.shields.io/bundlephobia/minzip/binary-util) | ||
![npm bundle size](https://deno.bundlejs.com/?q=binary-util&badge) | ||
![node-current](https://img.shields.io/node/v/binary-util) | ||
--> | ||
A utility library for working with binary data in. | ||
It does not have full support for all types of data, but it does have the ones I needed. | ||
## Usage | ||
A full example of how to use this library can be found in my [RE MSG library](https://github.com/beeequeue/remsg). | ||
Here are some non-exhaustive examples: | ||
### Decoder | ||
```typescript | ||
import { Decoder } from "binary-util" | ||
const data = Buffer.from([ | ||
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x21, | ||
]) | ||
const decoder = new Decoder(data) | ||
// You can use it to just read data straight from the buffer | ||
decoder.readString({ length: 5 }) // Hello | ||
decoder.readString({ length: 7 }) // ", World" | ||
// Utilities | ||
encoder.seek(-1) | ||
encoder.seek(1) | ||
encoder.alignTo(8) | ||
// Or you can use it more ergonomically when possible | ||
const decoder2 = new Decoder(Buffer.alloc(2, 2)) | ||
const result = { | ||
a: decoder2.readUint8(), // 2 | ||
b: decoder2.readUint8(), // 2 | ||
} | ||
``` | ||
### Encoder | ||
```typescript | ||
import { Encoder } from "binary-util" | ||
const encoder = new Encoder() | ||
encoder.writeString("Hello, World") | ||
encoder.seek(-1) | ||
encoder.seek(1) | ||
encoder.alignTo(8) | ||
encoder.writeUint8(2) | ||
encoder.goto(1) | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
23377
8
1
59
0
14