npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lainnao/chord-progression-parser-bundler

v0.6.2

Published

a converter from chord progression strings to AST

Downloads

16

Readme

chord-progression-parser

A converter from chord progression strings to AST built in Rust that outputs wasm, so it can be used from JavaScript too.

NOTE: This library releases multiple packages. GitHub release (latest SemVer)

Example

You can try it on CodeSandbox

example gif

Documents

How to use

Rust

  • Install

    cargo add chord-progression-parser
  • And use

    use chord_progression_parser::parse_chord_progression_string;
    
    fn main() {
      let input: &str = "
    @section=Intro
    [key=E]E - C#m(7) - Bm(7) - C#(7)
    F#m(7) - Am(7) - F#(7) - B
      
    @section=Verse
    E - C#m(7) - Bm(7) - C#(7)
    F#m(7) - Am(7) - F#(7) - B
    ";
    
        let result = parse_chord_progression_string(input);
        println!("{:#?}", result);
    }

JavaScript/TypeScript (using bundler, like Vite, or If you are using Next.js)

  • Install (example, use with Vite)

    npm install @lainnao/chord-progression-parser-bundler
    npm install -D vite-plugin-wasm
  • Edit vite.config.js

    import { defineConfig } from "vite";
    import wasm from "vite-plugin-wasm";
    
    export default defineConfig({
      plugins: [wasm()],
    });
  • And use

    import { parseChordProgressionString } from "@lainnao/chord-progression-parser-bundler/chord_progression_parser";
    
    const result = parseChordProgressionString("C");
    console.log(result);

JavaScript/TypeScript (server like Node.js, Bun)

  • Install

    npm install @lainnao/chord-progression-parser-node
  • And use

    import { parseChordProgressionString } from "@lainnao/chord-progression-parser-node/chord_progression_parser";
    
    const result = parseChordProgressionString("C");
    console.log(result);

JavaScript(CDN)

  • index.html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
      </head>
      <body>
        <h1>load wasm directly example</h1>
        <h2>parse C</h2>
        <pre id="result"></pre>
        <script type="module">
          import * as mod from "https://cdn.jsdelivr.net/npm/@lainnao/[email protected]/chord_progression_parser.js";
    
          (async () => {
            // initialize wasm
            await mod.default();
            // use
            const result = mod.parseChordProgressionString("C");
            console.log(result);
            document.querySelector("#result").innerHTML = JSON.stringify(
              result,
              null,
              2
            );
          })();
        </script>
      </body>
    </html>

Article