@nbsjs/core
TypeScript icon, indicating that this package has built-in type declarations

6.0.0 • Public • Published

nbs.js

Robust API for reading, manipulating, and writing OpenNBS files, inspired by NBSEditor and NBS4j.

It's cleanroom, too! No required dependencies!

NPM Badge Docs Badge

🔧 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/core@6.0.0)

🟢 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

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!

🔨 Building

Ensure that Bun is installed.

  1. Enter the directory containing the nbs.js source code in your terminal.
  2. Install the build dependencies via bun install.
  3. Run bun run build to bundle the ESM module.

Generated files:

  • dist/*.js: Bundled ESM files for Node.js and related
  • dist/*.d.ts: Generated TypeScript type bundle
  • public/docs/*: Generated web-based documentation

Package Sidebar

Install

npm i @nbsjs/core

Weekly Downloads

1

Version

6.0.0

License

MIT

Unpacked Size

101 kB

Total Files

7

Last publish

Collaborators

  • bentroen
  • encode42