Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@hazae41/cursor

hazae41481MIT2.0.7TypeScript support: included

Rust-like Cursor for TypeScript

cursor, zero-copy, encoding, decoding, buffer, bytes, protocol, packets, reader, writer, offset, asn1, der, ber, octets, stream, low-level, alloc, allocation, allocator, typescript, esmodules, tested, unit-tested

readme

Cursor

npm i @hazae41/cursor

Node Package 📦

Features

Current features

  • 100% TypeScript and ESM
  • No external dependencies
  • Zero-copy reading and writing
  • Rust-like patterns
  • Unit-tested

Usage

Cursor

Writing

const cursor = Cursor.allocUnsafe(1024)

cursor.tryWriteUint8(123).unwrap()
cursor.tryWriteUint16(1234).unwrap()

console.log(cursor.offset) // 3

Reading

const bytes = new Uint8Array(/*...*/)
const cursor = new Cursor(bytes)

const uint8 = cursor.tryReadUint8().unwrap()
const uint16 = cursor.tryReadUint16().unwrap()

console.log(cursor.offset) // 3