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 🙏

© 2024 – Pkg Stats / Ryan Hefner

epub-press-js

v0.5.3

Published

Javascript client for building books with EpubPress.

Downloads

30

Readme

epub-press-js

npm npm

A javascript client for building books with EpubPress.

Install

npm install --save epub-press-js

Test

Unit Tests

npm test

Browser Test

open tests/browserTest.html

NodeJS Test

node tests/nodeTest.js

Build

# Single build
npm run-script build

# Build + watch
npm start

Usage

Browser
<script src="node_modules/epub-press-js/build/index.js"></script>
<script>var EpubPress = window.EpubPress;</script>
NodeJS
const EpubPress = require('epub-press-js');
Creating a Book
const ebook = new EpubPress({
    title: 'Best of HackerNews',
    description: 'Favorite articles from HackerNews in May, 2016',
    sections: [
        {
            url: 'http://medium.com/@techBlogger/why-javascript-is-dead-long-live-php',
            html: '<html><body><p>Lulz.</p></body></html>',
        }
    ]
});

// OR

const ebook = new EpubPress({
    title: 'Best of HackerNews',
    description: 'Favorite articles from HackerNews in May, 2016',
    urls: [
        'http://medium.com/@techBlogger/why-js-is-dead-long-live-php'
    ]
});
Publishing
ebook.publish().then(() =>
    ebook.download();  // Default epub
    // or ebook.email('[email protected]')
).then(() => {
    console.log('Success!');
}).catch((error) => {
    console.log(`Error: ${error}`);
});
Checking Status
ebook.checkStatus().then((status) => {

}).catch((error) => {});
Event Listening
const onStatusUpdate = (status) => { console.log(status.message); };

// Adding callback
ebook.on('statusUpdate', onStatusUpdate);

// Removing callback
ebook.removeListener('statusUpdate', onStatusUpdate)
Check for updates
// epub-press-js updates
EpubPress.checkForUpdates().then((message) => {
    console.log(message); // Undefined if no update required
});

// epub-press-chrome updates
EpubPress.checkForUpdates('epub-press-chrome', '0.9.0').then((message) => {
    console.log(message);
});

API

new EpubPress(metadata) => ebook
  • metadata.sections: Object with the url and html for a chapter.
  • metadata.urls: Array of urls.
  • metadata.title: Title for the book.
  • metadata.description: Description for the book.
  • metadata.filetype: File format to use for downloads.
ebook.publish() => Promise
ebook.download(filetype) => Promise
  • filetype: 'mobi' or 'epub' (Default 'epub')
ebook.email(email, filetype) => Promise
  • filetype: 'mobi' or 'epub' (Default 'epub')
  • email: Email address to deliver ebook to.
ebook.checkStatus() => Promise => status
  • status.progress: Percentage complete. (0 -> 100)
  • status.message: Status message.
ebook.on('statusUpdate', (status) => {}) => callback
  • status.progress: Percentage complete. (0 -> 100)
  • status.message: Description of current step.
ebook.removeListener(eventName, callback)
  • eventName: Name of the event callback exists on.
  • callback: Listener to be removed.
EpubPress.checkForUpdates(clientName, clientVersion) => Promise => Update Message | undefined
  • clientName: EpubPress client library to check. (Default: epub-press-js)
  • clientVersion: Version of client. (Default: EpubPress.VERSION)

Issues

  • Safari downloads the file as Unknown. You then must manually add the file extension (eg. .epub or .mobi)

Feel free to report any other issues:

  • In the Github repo: https://github.com/haroldtreen/epub-press-clients
  • By email: [email protected]

Related

  • Website: https://epub.press
  • Chrome Extension: https://chrome.google.com/webstore/detail/epubpress-create-ebooks-f/pnhdnpnnffpijjbnhnipkehhibchdeok