It's cleanroom, too! No required dependencies!
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/core@6.0.0
)
Add the @nbsjs/core
package using the package manager of your choice.
import { Song } from "@nbsjs/core";
<script type="module">
import { Song } from "https://esm.run/@nbsjs/core";
</script>
import { Song } from "https://esm.run/@nbsjs/core";
How do I use this?
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!
🟢 Node.js
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);
🌐 Browser
<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>
🦕 Deno
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);
Is there a demo?
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.
Where's the changelog?
I don't create GitHub releases, but I do keep a changelog here!
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