nibbit-nolong

NBT encoder and decoder

npm install nibbit-nolong
2 downloads in the last week
4 downloads in the last month

Nibbit

JavaScript NBT encoder and decoder

Overview

Nibbit is an easy to use encoder and decoder for the NBT serialisation format, created for and popularised by the game "Minecraft". It'll decode uncompressed NBT data only - decompression is your job.

Features

  1. Accurate encoding and decoding of most NBT tag types (see below for details)
  2. Convenient AST generator functions
  3. Asynchronous and streaming parser (thanks to node-binary)

Bugs and Limitations

  1. Can't represent integers above 2^53 accurately due to JavaScript's numeric type being double all the time.
  2. Can't encode arbitrary objects for the same reason. Not enough information is available about the numbers being encoded. All encoding has to be done on a specially constructed AST.

Documentation

Take a look at docs/ in the repo or the same thing hosted on github. Please note that these are HTML files generated by docco so you can also just read the comments in the source files in lib/ if you like.

Example Usage

var fs = require("fs"),
    zlib = require("zlib"),
    nibbit = require("nibbit");

// decoding
fs.readFile("./data/test.nbt", function(err, compressed) {
  zlib.gunzip(compressed, function(err, uncompressed) {
    nbt.decode(data, function(err, decoded) {
      console.log(decoded);
    });
  });
});

// encoding and manual AST construction
var ast = nbt.compound([
  nbt.string("Bananrama", "name"),
], "hello world");

nibbit.encode(ast, function(err, uncompressed) {
  console.log(uncompressed);
});

License

3-clause BSD. A copy is included with the source.

Contact

npm loves you