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

treeify-book

v0.0.2

Published

Converts a book to a tree of content, and vice versa

Readme

Book Tree Maker

This is designed to take a basic e-book and split it into: header, table of contents, any chapters, and any appendix

Much of the code was designed with the idea it could be expanded upon. This is an MVP and there are several further use cases to take into consideration, such as:

  • Add more configuration settings
  • More flexible parsing (ie: allows files with variation in delimeters; it's very strict assumptions right now)
  • Nesting chapters in volumes or books (The example Monte Cristo has volumes, which are currently ignored)
  • Individual chapter analysis, such as characters who appear, over used words, word count, etc.
  • Etc.

Some code may seem over generalized or avoiding simplification for given use cases because of this. Most have been commented.

Example Usage

var treeifyBook = require('treeify-book');

// Splits book content into seperate files
// returns a promise
treeifyBook.extractBook({
	bookName: './example/MonteCristo.txt',
	saveToPath: './example/MonteCristo/'
});

// Repackages book content into one file
// returns a promise
treeifyBook.packageBook({
	bookPath: './example/MonteCristo/',
	saveToFile: './example/MonteCristo_RECREATED.txt'
});

Assumptions

Book files are *.txt and in the following format (Extracted/created accordingly)...

Title: Book Title
Author: Author Name

<Rest of Header>

------------------ Create/Fetch: HEADER.txt

Contents
Chapter 1. Chapter title
<Rest of Contents>

------------------ Create/Fetch: CONTENTS.txt

Chapter 1. Chapter title
<Chapter content>

------------------ Create/Fetch: chapters/Chapter 1.txt

<Repeat chapters as needed>

------------------ 

Appendix <or 'Footnotes'>
<Rest of file>

------------------ Create/Fetch: APPENDIX.txt

Files that don't follow this pattern may be subject to weird parsing errors. Parsing is not case sensitive and leading/trailing spaces are ignored.