Skip to content

Latest commit

 

History

History
70 lines (41 loc) · 1.37 KB

README.md

File metadata and controls

70 lines (41 loc) · 1.37 KB

Pubsie

A JavaScript package for parsing EPUB files and extracting their contents. This package provides a convenient way to extract metadata, chapters, and other resources from EPUB files in your JavaScript applications.

This package will aim to eventually adhere, in full, to the EPUB specifications documented here

Usage/Examples

const pubsie = require("pubsie");

let pub = new pubsie('path/to/epub');

pub.on("error", (err) => {
  console.log(err.message);

  if (err.data.name == "NoNcxError") {
    // ... process error
  };
});

pub.parse(); // always call after event listener

pub.buildCache('path/to/write/location') // build a cache of parsed data

console.log(pub.epub) // .epub property stores parsed data

Installation

Install pubsie with npm

  npm i pubsie

Running Tests

in tests directory, create a data directory and place epub files inside

tests
├───data
│   ├───moby-dick.epub
│   └───dracula.epub
└───global

To run tests, run the following command

  npm run test

Important

all epubs for testing are derived from Project Gutenberg

License

Pubsie is provided under the MIT license

Author