Skip to content

Latest commit

 

History

History

bytebuffer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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!