nbt
Version:
A parser and serializer for NBT archives
1,096 lines (341 loc) • 13.8 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: nbt</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Module: nbt</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
</div>
<h3 class="subsection-title">Classes</h3>
<dl>
<dt><a href="module-nbt.Reader.html">Reader</a></dt>
<dd></dd>
<dt><a href="module-nbt.Writer.html">Writer</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id=".tagTypeNames"><span class="type-signature">(static) </span>tagTypeNames<span class="type-signature"> :Object.<number, string></span></h4>
<div class="description">
A mapping from NBT type numbers to type names.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object.<number, string></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="nbt.js.html">nbt.js</a>, <a href="nbt.js.html#line60">line 60</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-nbt.html#.tagTypes">module:nbt.tagTypes</a></li>
</ul>
</dd>
</dl>
<h4 class="name" id=".tagTypes"><span class="type-signature">(static) </span>tagTypes<span class="type-signature"> :Object.<string, number></span></h4>
<div class="description">
A mapping from type names to NBT type numbers.
<a href="module-nbt.Writer.html">module:nbt.Writer</a> and <a href="module-nbt.Reader.html">module:nbt.Reader</a>
have correspoding methods (e.g. <a href="module-nbt.Writer.html#int">module:nbt.Writer#int</a>)
for every type.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object.<string, number></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="nbt.js.html">nbt.js</a>, <a href="nbt.js.html#line39">line 39</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-nbt.html#.tagTypeNames">module:nbt.tagTypeNames</a></li>
</ul>
</dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id=".parse"><span class="type-signature">(static) </span>parse<span class="signature">(data, callback)</span><span class="type-signature"></span></h4>
<div class="description">
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.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">ArrayBuffer</span>
|
<span class="param-type">Buffer</span>
</td>
<td class="description last">gzipped or uncompressed data</td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">parseCallback</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="nbt.js.html">nbt.js</a>, <a href="nbt.js.html#line641">line 641</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-nbt.html#.parseUncompressed">module:nbt.parseUncompressed</a></li>
<li><a href="module-nbt.Reader.html#compound">module:nbt.Reader#compound</a></li>
</ul>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>nbt.parse(buf, function(error, results) {
if (error) {
throw error;
}
console.log(result.name);
console.log(result.value.foo);
});</code></pre>
<h4 class="name" id=".parseUncompressed"><span class="type-signature">(static) </span>parseUncompressed<span class="signature">(data)</span><span class="type-signature"> → {Object}</span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">ArrayBuffer</span>
|
<span class="param-type">Buffer</span>
</td>
<td class="description last">an uncompressed NBT archive</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="nbt.js.html">nbt.js</a>, <a href="nbt.js.html#line594">line 594</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-nbt.html#.parse">module:nbt.parse</a></li>
<li><a href="module-nbt.html#.writeUncompressed">module:nbt.writeUncompressed</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
a named compound
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>nbt.readUncompressed(buf);
// -> { name: 'My Level',
// value: { foo: { type: int, value: 42 },
// bar: { type: string, value: 'Hi!' }}}</code></pre>
<h4 class="name" id=".writeUncompressed"><span class="type-signature">(static) </span>writeUncompressed<span class="signature">(value)</span><span class="type-signature"> → {ArrayBuffer}</span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">a named compound
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">the top-level name</td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">a compound</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="nbt.js.html">nbt.js</a>, <a href="nbt.js.html#line569">line 569</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-nbt.html#.parseUncompressed">module:nbt.parseUncompressed</a></li>
<li><a href="module-nbt.Writer.html#compound">module:nbt.Writer#compound</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">ArrayBuffer</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>nbt.writeUncompressed({
name: 'My Level',
value: {
foo: { type: int, value: 42 },
bar: { type: string, value: 'Hi!' }
}
});</code></pre>
<h3 class="subsection-title">Type Definitions</h3>
<h4 class="name" id="~parseCallback"><span class="type-signature"></span>parseCallback<span class="signature">(error, result)</span><span class="type-signature"></span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>result</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">a named compound
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">the top-level name</td>
</tr>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">the top-level compound</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="nbt.js.html">nbt.js</a>, <a href="nbt.js.html#line610">line 610</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-nbt.html">nbt</a></li></ul><h3>Classes</h3><ul><li><a href="module-nbt.Reader.html">Reader</a></li><li><a href="module-nbt.Writer.html">Writer</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sun Dec 16 2018 05:05:14 GMT+0100 (CET)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>