npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parsenbt-js

v3.1.0

Published

A JavaScript-based minecraft NBT parser and serializer.

Downloads

65

Readme

ParseNBT.js

ParseNBT.js is a JavaScript-based minecraft NBT parser and serializer.

Install

npm i parsenbt-js

Usage

Reader

const fs = require('fs'), NBT = require('parsenbt-js');

var binData = fs.readFileSync('./path/of/nbt.nbt');
// The NBT.Reaer returns an object
console.log(NBT.Reader(binData));

Writer

const fs = require('fs'), NBT = require('parsenbt-js');

var nbtData = {
  "comp>": {
    "i32>count": 100,
    "list>pos": [ "i32", 0, 0, 0 ],
    "i64>ticks": { "low": 114514, "high": 1919810 }
  }
};

// The NBT.Writer returns a buffer
// The second param determined the byte order
// little-endian if it's true
console.log(NBT.Writer(nbtData, !0));

API

See API.md

Data Structure

ParseNBT.js' output uses a special data structure for keys of the object.

For example:

{
  "comp>": { 
    "i32>count": 100,
    "list>pos": [ "i32", 0, 0, 0 ],
    "i64>ticks": { "low": 114514, "high": 1919810 }
  }
}

In the object, keys are separated into two parts with character >.

In the left-hand-side is the tag type, and the right-hand-side is the tag name. Tag name can be an empty string like above.

The comparison table between the type string and the actual type is as follows: | Tag ID | Tag Type | Tag Type String | | ---- | ---- | ---- | | 0 | TAG_End | null | | 1 | TAG_Byte | i8 | | 2 | TAG_Short | i16 | | 3 | TAG_Int | i32 | | 4 | TAG_Long | i64 | | 5 | TAG_Float | f32 | | 6 | TAG_Double | f64 | | 7 | TAG_Byte_Array | a8 | | 8 | TAG_String | str | | 9 | TAG_List | list | | 10 | TAG_Compound | comp | | 11 | TAG_Int_Array | a32 | | 12 | TAG_Long_Array | a64 |

Especially, the type of elements in TAG_List is the first element of the list array. And for TAG_Long, it'll be formatted into an object which has two values named low and high, that produces the high 32 bits and the low 32 bits separately.