Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

binary-util

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binary-util - npm Package Compare versions

Comparing version 0.0.0 to 1.0.0

CHANGELOG.md

10

package.json
{
"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)
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc