Fixing missing return value

This commit is contained in:
Fabian Stamm 2018-09-21 12:33:32 +02:00
parent 6a07f1fa53
commit 05667d10ba
5 changed files with 7 additions and 21 deletions

5
lib/epub.d.ts vendored
View File

@ -1,3 +1,4 @@
/// <reference types="node" />
import * as JSZip from "jszip";
/**
* new EPub(fname[, imageroot][, linkroot])
@ -155,7 +156,7 @@ export declare class EPub {
* an error object, image buffer and image content-type.
* Return only images with mime type image
**/
getImage(id: any): Promise<void>;
getImage(id: any): Promise<Buffer>;
/**
* EPub#getFile(id, callback) -> undefined
* - id (String): Manifest id value for a file
@ -164,5 +165,5 @@ export declare class EPub {
* Finds a file for an id. Returns the file as Buffer. Callback gets
* an error object, file contents buffer and file content-type.
**/
getFile(id: any): Promise<void>;
getFile(id: any): Promise<Buffer>;
}

View File

@ -632,14 +632,7 @@ class EPub {
**/
async getFile(id) {
if (this.manifest[id]) {
let data = await this.zip.files[this.manifest[id].href].async("nodebuffer");
// this.zip.files(this.manifest[id].href, (function (err, data) {
// if (err) {
// callback(new Error("Reading archive failed"));
// return;
// }
// callback(null, data, this.manifest[id]['media-type']);
// }).bind(this));
return await this.zip.files[this.manifest[id].href].async("nodebuffer");
}
else {
throw new Error("File not found");

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"name": "epub",
"description": "Parse ePub electronic book files with Node.JS",
"version": "0.3.1",
"version": "0.3.2",
"author": "Andris Reinman",
"contributors": [
{

View File

@ -728,15 +728,7 @@ export class EPub {
**/
async getFile(id) {
if (this.manifest[id]) {
let data = await this.zip.files[this.manifest[id].href].async("nodebuffer");
// this.zip.files(this.manifest[id].href, (function (err, data) {
// if (err) {
// callback(new Error("Reading archive failed"));
// return;
// }
// callback(null, data, this.manifest[id]['media-type']);
// }).bind(this));
return await this.zip.files[this.manifest[id].href].async("nodebuffer");
} else {
throw new Error("File not found");
}