Socket
Socket
Sign inDemoInstall

bytewriter

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bytewriter

Simple binary byte stream implementation with support for reading/writing numbers, strings, and varints (zigzag or unsigned) in both little and big endian encoding


Version published
Maintainers
1
Created

Changelog

Source

1.1.0

Readme

Source

node-bytewriter

NPM version Build Status Try it on gitpod PrismarineJS Discord

A simple zero-dep binary byte stream implementation for Node.js and the browser with support for reading and writing numbers, strings, and varints (zigzag or unsigned) in both little and big endian encoding.

Install

npm install bytewriter

Usage

Simple example to create a new empty Buffer stream:

const ByteStream = require('bytewriter')
const stream = new ByteStream()
stream.writeStringNT("hello world!") // write a string with a null term at end
const buffer = stream.getBuffer()
console.assert(buffer.equals(Buffer.from('hello world!\0'))

Load an existing one:

const BinaryStream = require('bytewriter')
const stream = new BinaryStream(Buffer.from('10 10 10', 'hex'))
const a = stream.readUInt8()
const b = stream.readUInt16()

API

See the typescript types here for the full API

License

MIT

Keywords

FAQs

Last updated on 05 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc