JSPM

@nbsjs/core

6.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 43
  • Score
    100M100P100Q64356F
  • License MIT

Robust API for reading and writing OpenNBS files.

Package Exports

  • @nbsjs/core
  • @nbsjs/core/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@nbsjs/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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