Skip to content

Commit

Permalink
Update outdated information in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
encode42 committed Jul 2, 2024
1 parent 39b34a8 commit b9eef71
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
[Docs]: https://encode42.github.io/nbs.js/docs/

[Docs Badge]: https://img.shields.io/badge/Docs-3178C6?labelColor=3178C6&logo=typescript&logoColor=white&style=flat-square

[NPM]: https://www.npmjs.com/package/@encode42/nbs.js

[NPM Badge]: https://img.shields.io/npm/v/@encode42/nbs.js?label=​&color=cb0000&labelColor=cb0000&logo=npm&logoColor=white&style=flat-square

[Changelog]: changelog.md

[Demo]: https://encode42.dev/nbs

[Demo Badge]: https://img.shields.io/badge/Demo-202b38?labelColor=202b38&logo=svelte&logoColor=white&style=flat-square

[Actions]: https://github.com/encode42/nbs.js/actions/workflows/build.yml

[Actions Badge]: https://img.shields.io/github/actions/workflow/status/encode42/nbs.js/build.yml?style=flat-square

[Support]: https://encode42.dev/support

[Support Badge]: https://img.shields.io/discord/646517284453613578?color=7289da&labelColor=7289da&label=​&logo=discord&logoColor=white&style=flat-square

[Codacy]: https://app.codacy.com/gh/encode42/nbs.js/dashboard

[Codacy Badge]: https://img.shields.io/codacy/grade/68f12c67186549b88ab7ada56ac83efc?color=172B4D&labelColor=172B4D&label=​&logo=codacy&style=flat-square

<img src=".github/assets/badge-lq.png" align="right" id="header">
Expand All @@ -24,19 +36,21 @@

### 🔧 Including
> [!TIP]
> When using `esm.run` links, it's recommended to use versioned links! (e.g. `@encode42/[email protected]`)
> When linking to `esm.run`, it's recommended to use a version! (e.g. `@encode42/[email protected]`)
> [!IMPORTANT]
> This library does not bundle CommonJS modules. Legacy Node.js applications may not be compatible.
#### 🟢 Node.js
Add the [`@encode42/nbs.js` package from NPM][NPM] using the package manager of your choice.

```js
import { Song } from "@encode42/nbs.js"; // ESM (TypeScript, Vite, etc.)

const { Song } = require("@encode42/nbs.js"); // CJS (vanilla Node.js)
import { Song } from "@encode42/nbs.js";
```

#### 🌐 Browser
```html

<script type="module">
import { Song } from "https://esm.run/@encode42/nbs.js";
</script>
Expand All @@ -63,14 +77,9 @@ There are more examples designed for use with Node.js in the [examples directory
</summary>

```js
// ESM (TypeScript, Vite, etc.)
import { readFileSync } from "node:fs";
import { fromArrayBuffer } from "@encode42/nbs.js";

// CJS (vanilla Node.js)
const { readFileSync } = require("fs");
const { fromArrayBuffer } = require("@encode42/nbs.js");

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
Expand Down Expand Up @@ -129,9 +138,7 @@ console.dir(song);
<b>Is there a demo?</b>
</summary>

Yes! A demo site is located [here](https://encode42.dev/nbs). It serves as an example of how to read NBS files, allows you to edit the song structure, and plays the result through the browser.

This repository also contains [tests](/tests) that could be used as examples, and [examples designed for Node.js](/examples).
Currently, a website to demonstrate usage of the library does not exist. However, this repository contains [tests](/tests) that could be used as examples, and [actual examples designed for Node.js and similar](/examples).
</details>

<details>
Expand All @@ -143,13 +150,13 @@ I don't create GitHub releases, but I do keep a changelog [here][Changelog]!
</details>

### 🔨 Building
Ensure [PNPM](https://pnpm.io/) and [Node.js](https://nodejs.org/) are installed.
Ensure that [Bun](https://bun.sh) is installed.

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

Generated files:
- `dist/*.js`: ESM bundle files for Node.js and related
- `dist/*.global.js`: UMD bundle files for browser scripts
- `build/`: Built ES2020 files.
- `dist/*.js`: Bundled ESM files for Node.js and related
- `dist/*.d.ts`: Generated TypeScript type bundle
- `public/docs/*`: Generated web-based documentation

0 comments on commit b9eef71

Please sign in to comment.