@nbsjs/core
v6.0.0
Published
Robust API for reading and writing OpenNBS files.
Downloads
6
Readme
nbs.js
Robust API for reading, manipulating, and writing OpenNBS files, inspired by NBSEditor and NBS4j.
It's cleanroom, too! No required dependencies!
🔧 Including
[!IMPORTANT]
This library does not bundle CommonJS modules. Legacy Node.js applications may not be compatible.
[!TIP] When linking to
esm.run
, it's recommended to use a version! (e.g.@nbsjs/[email protected]
)
🟢 Node.js
Add the @nbsjs/core
package using the package manager of your choice.
import { Song } from "@nbsjs/core";
🌐 Browser
<script type="module">
import { Song } from "https://esm.run/@nbsjs/core";
</script>
🦕 Deno
import { Song } from "https://esm.run/@nbsjs/core";
❔ FAQ
Install nbs.js for your platform, then refer to the documentation and examples below.
There are more examples designed for use with Node.js in the examples directory!
import { readFileSync } from "node:fs";
import { fromArrayBuffer } from "@nbsjs/core";
const songFile = readFileSync("song.nbs"); // Read the selected NBS file
const buffer = new Uint8Array(songFile).buffer; // Convert it into an ArrayBuffer
const song = fromArrayBuffer(buffer); // Parse the buffer
console.dir(song);
<input type="file" id="file-input">
<script type="module">
import { fromArrayBuffer } from "https://esm.run/@nbsjs/core"
window.addEventListener("load", () => {
const input = document.getElementById("file-input");
// Initialize file input
input.addEventListener("change", () => {
const songFile = input.files[0]; // Read the selected NBS file
songFile.arrayBuffer().then(buffer => { // Convert it into an ArrayBuffer
const song = fromArrayBuffer(buffer); // Parse the buffer
console.dir(song);
});
});
});
</script>
import { fromArrayBuffer } from "https://esm.run/@nbsjs/core";
const songFile = await Deno.readFile("song.nbs"); // Read the selected NBS file
const buffer = new Uint8Array(songFile).buffer; // Convert it into an ArrayBuffer
const song = fromArrayBuffer(buffer); // Parse the buffer
console.dir(song);
Currently, a website to demonstrate usage of the library does not exist. However, this repository contains tests that could be used as examples, and actual examples designed for Node.js and similar.
I don't create GitHub releases, but I do keep a changelog here!
🔨 Building
Ensure that Bun is installed.
- Enter the directory containing the nbs.js source code in your terminal.
- Install the build dependencies via
bun install
. - Run
bun run build
to bundle the ESM module.
Generated files:
dist/*.js
: Bundled ESM files for Node.js and relateddist/*.d.ts
: Generated TypeScript type bundlepublic/docs/*
: Generated web-based documentation