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

lyrics-structure

v1.4.1

Published

Parse lyrics with bracketed sections into structured parts, with slide generation for presentations

Downloads

369

Readme

lyrics-structure

A TypeScript library for parsing lyrics with bracketed sections into structured parts, with built-in slide generation for presentations.

Installation

npm install lyrics-structure

Usage

Parsing Lyrics into Structured Parts

import { getLyricsParts } from 'lyrics-structure';

const lyrics = `[verse 1] (first time)
This is the first verse
[/verse 1]

[chorus]
This is the chorus
[/chorus]

[verse 1] (second time)
[/verse 1]`;

const parts = getLyricsParts(lyrics);

Result:

[
  { name: "verse 1", repetition: false, indication: "first time", content: "This is the first verse" },
  { name: "chorus", repetition: false, indication: null, content: "This is the chorus" },
  { name: "verse 1", repetition: true, indication: "second time", content: "This is the first verse" }
]

Repeated sections automatically carry forward the content from their first occurrence.

Generating Slides

import { getSlideParts } from 'lyrics-structure';

const slides = getSlideParts(lyrics);       // default: 4 lines per slide
const slides2 = getSlideParts(lyrics, 2);   // custom: 2 lines per slide

Each slide is a string. The function splits content at:

  • The configured maxLines limit (default 4)
  • Empty lines (natural paragraph breaks)
  • When 2+ lines in a slide exceed 60 characters

API

getLyricsParts(lyrics: string): LyricPart[]

Parses raw lyrics text into an array of structured parts.

Section format:

[section name] (optional indication)
content lines
[/section name]
  • Sections are delimited by [name] and [/name] brackets
  • Indications are optional parenthesized text after the opening bracket: [verse] (softly)
  • Repeated section names are flagged with repetition: true and inherit content from the first occurrence
  • Text outside any brackets is captured as unnamed parts

getSlideParts(text?: string, maxLines?: number): string[]

Splits lyrics into presentation-ready slide strings.

| Parameter | Type | Default | Description | |------------|----------|---------|------------------------------------| | text | string | — | Raw lyrics text | | maxLines | number | 4 | Maximum number of lines per slide |

Returns an empty array if text is undefined or null.

LyricPart

type LyricPart = {
  name: string | undefined;       // section name, undefined for unbracketed content
  repetition: boolean;            // true if this section name appeared earlier
  indication: string | null;      // parenthesized text, e.g. "(softly)"
  content: string | undefined;    // the lyrics text of the section
};

Features

  • Parse bracketed lyric sections into structured data
  • Automatic repetition detection across sections
  • Optional per-section indications/annotations
  • Preserve content outside of bracketed sections
  • Slide generation with configurable line limits
  • Smart slide breaking on empty lines and long lines
  • Full TypeScript type support

License

MIT