Module: nbt

Classes

Reader
Writer

Members

(static) tagTypeNames :Object.<number, string>

A mapping from NBT type numbers to type names.
Type:
  • Object.<number, string>
Source:
See:

(static) tagTypes :Object.<string, number>

A mapping from type names to NBT type numbers. module:nbt.Writer and module:nbt.Reader have correspoding methods (e.g. module:nbt.Writer#int) for every type.
Type:
  • Object.<string, number>
Source:
See:

Methods

(static) parse(data, callback)

This accepts both gzipped and uncompressd NBT archives. If the archive is uncompressed, the callback will be called directly from this method. For gzipped files, the callback is async. For use in the browser, window.zlib must be defined to decode compressed archives. It will be passed a Buffer if the type is available, or an Uint8Array otherwise.
Parameters:
Name Type Description
data ArrayBuffer | Buffer gzipped or uncompressed data
callback parseCallback
Source:
See:
Example
nbt.parse(buf, function(error, results) {
    if (error) {
        throw error;
    }
    console.log(result.name);
    console.log(result.value.foo);
});

(static) parseUncompressed(data) → {Object}

Parameters:
Name Type Description
data ArrayBuffer | Buffer an uncompressed NBT archive
Source:
See:
Returns:
a named compound
Type
Object
Example
nbt.readUncompressed(buf);
// -> { name: 'My Level',
//      value: { foo: { type: int, value: 42 },
//               bar: { type: string, value: 'Hi!' }}}

(static) writeUncompressed(value) → {ArrayBuffer}

Parameters:
Name Type Description
value Object a named compound
Properties
Name Type Description
name string the top-level name
value Object a compound
Source:
See:
Returns:
Type
ArrayBuffer
Example
nbt.writeUncompressed({
    name: 'My Level',
    value: {
        foo: { type: int, value: 42 },
        bar: { type: string, value: 'Hi!' }
    }
});

Type Definitions

parseCallback(error, result)

Parameters:
Name Type Description
error Object
result Object a named compound
Properties
Name Type Description
name string the top-level name
value Object the top-level compound
Source: