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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ebookjs

v0.6.1

Published

Tiny utility for reading ebook file uploads

Readme

ebookjs

A library for easy reading of ebook files. Currently only supports reading .epub files.

This library is solely focused on reading files and returning objects you can work with, there is no GUI reader functionality currently or planned. However, it is very simple to make your own with what ebookjs gives you; there is a simple VueJS example at the end of this readme.

Below is a simple example

<input id="upload" type="file" accept=".epub" size="1">
<script>
import ebookjs from 'ebookjs'
function handleFileSelect (evt) {
  ebookjs.fileToContent(evt.target.files[0]).then(content => {
    processChapters(content.chapters) // do whatever you want
  })
}

document.getElementById('upload').addEventListener('change', handleFileSelect, false);
</script>

fileToContent

fileToContent returns an object of type EbookContent, which has the following fields:

chapters : List of chapters. Structure of chapters described below

stylesheets : Object where keys are stylesheet filenames, values are text contents

images : Object where keys are image filenames, values are dataURLs (so you can use <img :src="data.images[filename]")

metadata : Object with all metadata entries. Only title, identifier, and language are guaranteed to be non-null. Typically also includes information like creator, publisher, date, etc. Values are either Strings or arrays of Strings. Array of Strings happens when a metadata tag is specified multiple times, for example metadata.subject == ['Non-fiction', 'Biology']

Chapters

Note that a chapter can also represent files like the Table of Contents, Preface, Introduction etc (it's all .html and .xhtml files packaged in the epub)

Type is EbookChapter. Chapters have the following fields:

name : Name of the chapter

filename : Name of file containing the chapter

html : HTMLDocument object of the original file's html. You can do look-ups like chapter.html.getElementsByTagName("p")

text: Text content of the file. Note that right now this is recieved by reading innerText of the <body> tag, so whitespace might be messy in some cases

To-do list

  1. Support for other filetypes, especially .mobi
  2. Fixing bugs and edge/cases if any arise

Please do open pull requests if you improve this, I can't say how much time I will have for maintaining and improving this

VueJS ebook reader implementation

Below is a way you might use ebookjs and VueJS to create an online ebook reader. From there, it's up to you what other features to provide, how to lay it out, etc.

<div class="reader">
    <!-- Basic chapter navigation; arrows and dropdown list -->
    <div class="chapter-nav" v-if="chapters && chapters[index]">
      <div class="arrow btn" :class="{'disabled': index == 0}" @click="index--">Previous Chapter</div>
      <select v-model="index" style="max-width:30%;margin: 0px 20px;">
        <option v-for="(ch,i) in chapters" :key="ch" :value="i">{{i+1}}. {{ch.name}}</option>
      </select>
      <div class="arrow btn" :class="{'disabled': index + 1 >= chapters.length}" @click="index++">Next Chapter</div>
    </div>
    <!-- v-html using the .html field shows properly formatted chapter content -->
    <div class="chapter-content" v-if="chapters && chapters[index]" v-html="chapters[index].html.documentElement.innerHTML" />
  </div>