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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@chordsketch/chordpro-lite

v0.7.0

Published

Dependency-free ChordPro helpers — format detection, lyric extraction, and preview sampling — with no WebAssembly runtime

Readme

@chordsketch/chordpro-lite

npm

Dependency-free ChordPro helpers for ChordSketch — the Rust ChordPro / iReal Pro engine. Three questions about a chart can be answered with plain string work: which format is it, which words are the lyrics, and what do its opening lines look like. This package answers them with no dependencies at all — in particular no WebAssembly — so a server, an edge runtime, a build script or a CLI wrapper can sniff and index charts, and load @chordsketch/wasm or @chordsketch/node only when it actually needs to parse or render one.

Anything beyond those three questions — parsing, transposing, rendering, chord diagrams, iReal Pro charts — is the engine's job, and this package deliberately does not reimplement it.

Installation

npm install @chordsketch/chordpro-lite

Quick start

import { detectFormat, extractLyrics, extractPreview } from '@chordsketch/chordpro-lite';

const chart = `{title: Morning Light}
{artist: The Example Band}

{start_of_verse}
[C]Morning light on a [G]quiet street
[Am]Everything is [F]still
{end_of_verse}`;

detectFormat(chart);
// 'chordpro'

detectFormat('irealb://Morning%20Light=Example=Medium%20Swing=C=n=...');
// 'irealb'

extractLyrics(chart);
// 'Morning light on a quiet street\nEverything is still'

extractPreview(chart);
// [ { chords: ['C', 'G'], lyric: 'Morning light on a quiet street' },
//   { chords: ['Am', 'F'], lyric: 'Everything is still' } ]

extractLyrics removes each directive whole, so a metadata line such as {title: ...} disappears along with its value; a directive sitting inside a lyric line is removed while the surrounding words stay. Read the song's metadata from the engine's parser, not from this output.

API

| Export | Signature | Notes | |---|---|---| | detectFormat | (input: string) => ChartFormat \| null | 'chordpro', 'irealb', or null when the input matches neither. | | extractLyrics | (source: string) => string | Lyric words with chords and directives removed, lines rejoined with \n. '' for an instrumental. | | extractPreview | (source: string, options?: PreviewOptions) => PreviewLine[] | The opening chord / lyric lines, capped. | | ChartFormat | 'chordpro' \| 'irealb' | Type. | | PreviewLine | { chords: string[]; lyric: string } | Type. | | PreviewOptions | see below | Type. | | version | string | The package version. |

PreviewOptions

| Option | Type | Default | Meaning | |---|---|---|---| | maxLines | number | 2 | Maximum preview lines returned. Scanning stops once the cap is reached, so a long chart costs only its opening lines. 0 or less returns []. | | maxChordsPerLine | number | 6 | Maximum chord symbols kept per line; the rest are dropped. | | maxLyricChars | number | 40 | Maximum lyric length per line, counted in code points so a truncation never splits a character. 0 or less returns ''. |

How detectFormat decides

  1. An iReal Pro URL prefix (irealb://, irealbook://) → 'irealb'.
  2. A ChordPro directive — a value-less one such as {soc}, or any name followed by a colon such as {title: ...} → 'chordpro'.
  3. An inline chord such as [G] or [Cmaj7/E] → 'chordpro'.
  4. Otherwise null.

Braced text that is not a directive ({username}, {"key": "value"}) and bracketed text that is not a chord ([Verse], [invalid]) are deliberately not matched, so plain prose does not register as a chart. The list of value-less directive names is generated from the engine's directive catalog, so it cannot fall behind what the parser recognises.

This is a pre-flight sniff, not a parse. Once the engine is loaded, its own detect_format is the richer classifier — it additionally recognises plain chord-over-lyric sheets, which detectFormat reports as null.

Links

License

MIT