0.0.11 • Published 6 months ago

@types/epub v0.0.11

Weekly downloads
25
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/epub

Summary

This package contains type definitions for epub (https://github.com/julien-c/epub).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/epub.

index.d.ts

// Type definitions for epub
// Project: https://github.com/julien-c/epub
// Definitions by: Julien Chaumond <https://github.com/julien-c>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node" />

/**
 *  new EPub(fname[, imageroot][, linkroot])
 *  - fname (String): filename for the ebook
 *  - imageroot (String): URL prefix for images
 *  - linkroot (String): URL prefix for links
 *
 *  Creates an Event Emitter type object for parsing epub files
 *
 *      var epub = new EPub("book.epub");
 *      epub.on("end", function () {
 *           console.log(epub.spine);
 *      });
 *      epub.on("error", function (error) { ... });
 *      epub.parse();
 *
 *  Image and link URL format is:
 *
 *      imageroot + img_id + img_zip_path
 *
 *  So an image "logo.jpg" which resides in "OPT/" in the zip archive
 *  and is listed in the manifest with id "logo_img" will have the
 *  following url (providing that imageroot is "/images/"):
 *
 *      /images/logo_img/OPT/logo.jpg
 **/
declare module "epub" {

    import { EventEmitter } from "events";

    interface TocElement {
        level: number;
        order: number;
        title: string;
        id: string;
        href?: string | undefined;
    }

    class EPub extends EventEmitter {
        constructor(epubfile: string, imagewebroot?: string, chapterwebroot?: string);

        metadata: Object;
        manifest: Object;
        spine: Object;
        flow: Array<Object>;
        toc: Array<TocElement>;

        parse(): void;

        getChapter(chapterId: string, callback: (error: Error, text: string) => void): void;

        getChapterRaw(chapterId: string, callback: (error: Error, text: string) => void): void;

        getImage(id: string, callback: (error: Error, data: Buffer, mimeType: string) => void): void;

        getFile(id: string, callback: (error: Error, data: Buffer, mimeType: string) => void): void;
    }

    export = EPub;
}

Additional Details

  • Last updated: Thu, 08 Jul 2021 12:01:10 GMT
  • Dependencies: @types/node
  • Global values: none

Credits

These definitions were written by Julien Chaumond.

0.0.10

6 months ago

0.0.11

6 months ago

0.0.9

7 months ago

0.0.8

8 months ago

0.0.7

3 years ago

0.0.6

4 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago