Skip to content

ByteBuffer Module

npm versionDownloadsInstall sizenpmBuild 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:

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

Using extra methods:

ts
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!

🧾 Classes

Released under the MIT License.