13 stable releases

2.6.10 Aug 16, 2024
2.6.7 Aug 12, 2024
1.2.3 Dec 13, 2023
1.1.4 Nov 21, 2023

#1557 in Web programming

29 downloads per month

MIT license

3MB
3K SLoC

Rust 1.5K SLoC // 0.3% comments JavaScript 1K SLoC // 0.1% comments TypeScript 177 SLoC // 0.8% comments

@serenityjs/binarystream

Binarystream is a simple Rust package designed to simplify the streaming of binary data in Javascript and Typescript. While containing the super speeds of Rust, and the ecosystem of Javascript!

Example Usage

import { BinaryStream } from "@serenityjs/binarystream"

// Create a new stream without a given buffer.
const stream = new BinaryStream()

// Reading / Writing is allowed on the fly,
// which will automatically update the cursor offset depending on the type of call.
stream.writeUint8(255)
stream.writeString16("Hello, World!")

// Converting the stream to a buffer!
const buffer = stream.getBuffer()

// Create another stream based on our output buffer from the previous stream.
const output = new BinaryStream(buffer)

// Reading the data in order.
stream.readUint8() // Expected output: 255
stream.readString16() // Expected output: "Hello, World!"

Dependencies

~1.3–6MB
~43K SLoC