JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 889
  • Score
    100M100P100Q104493F
  • License MIT

A library to read and write NBT files on the web!

Package Exports

  • nbtify
  • nbtify/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nbtify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NBTify

npm downloads

Following in the footsteps of NBT.js and Prismarine-NBT, NBTify is a JavaScript library that allows for the parsing of NBT files on the web!

I started this project as a learning experience to try and make my own NBT parser from scratch. I didn't have much success in making it work reliably, so I've decided to make a brand-new fork of NBT.js that will support Bedrock Edition's little endian NBT format, one of my goals that spurred the idea for making a new library.

Prismarine-NBT seemed like a viable option to NBT.js, as it supports both Bedrock and Java formats. However, it doesn't support the browser out of the box, and bundling it seems fairly bloated just to support the browser. NBT.js is really compact, so I didn't want to take the option with more dependencies.

I really like the functionality of Prismarine-NBT and the simplicity of NBT.js, so I thought, why not meet somewhere in the middle?

NBTify has entered the chat!

Usage

Importing NBTify in the browser:

<script type="module">
  import * as NBT from "https://cdn.jsdelivr.net/npm/nbtify/dist/index.min.js";
</script>

Importing NBTify in Node:

import * as NBT from "nbtify";

Reading a file using the Fetch API in the browser:

const response: Response = await fetch("./bigtest.nbt");
const arrayBuffer: ArrayBuffer = await response.arrayBuffer();
const data: NBTData = await NBT.read(arrayBuffer);

Reading a file using the File System module in Node:

import { readFile } from "node:fs/promises";

const buffer: Buffer = await readFile("./bigtest.nbt");
const data: NBTData = await NBT.read(buffer);

Writing to a file using the File API in the browser:

const result: Uint8Array = await NBT.write(data);
const file: File = new File([result],"bigtest.nbt");

Writing to a file using the File System module in Node:

import { writeFile } from "node:fs/promises";

const result: Uint8Array = await NBT.write(data);
await writeFile("./bigtest.nbt",result);