@xmcl/bytebuffer
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

ByteBuffer Module

npm version Downloads Install size npm Build Status

Provide some functions to query Minecraft server status. Port from bytebuffer.js.

Usage

Should similar to the bytebuffer in java.

You can also reference the bytebuffer.js.

There are sevearl notable differences:

  • Remove string methods as nodejs have better string encoding/decoding support.
  • This module only release one version using DataView. Should compatible for both browser and nodejs.
  • This module use BigInt to represent the long type.
  • Split non-common methods support into separate files. (Hope to reduce the build size)
  • Support esm (mjs)

Common usage:

import { ByteBuffer } from '@xmcl/bytebuffer'
const bb = ByteBuffer.allocate(10)
// similar to java's ByteBuffer

Using extra methods:

import { ByteBuffer } from '@xmcl/bytebuffer'
import '@xmcl/bytebuffer/varint64' // importing this will inject the varint64 methods to ByteBuffer

const bb = ByteBuffer.allocate(10)
bb.writeVarint64(BigInt(1234567890)) // now this is avaiable!

Package Sidebar

Install

npm i @xmcl/bytebuffer

Weekly Downloads

5

Version

0.1.1

License

MIT

Unpacked Size

469 kB

Total Files

35

Last publish

Collaborators

  • ci010