Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initBook(first) {
const { url, tocChanged, epubInitOptions } = this.props;
if (this.book) {
this.book.destroy();
}
this.book = new Epub(url, epubInitOptions);
this.book.loaded.navigation.then(({ toc }) => {
this.setState(
{
isLoaded: true,
toc: toc
},
() => {
tocChanged && tocChanged(toc);
this.initReader();
}
);
});
}
const loadMetadata = async(eBookName, rawEBookData) => new Promise(async (resolve, reject) => {
try {
var doc = undefined
var inputMetadata = undefined
var fingerprint = undefined
if (eBookName.endsWith(".epub")) {
doc = new Epub(rawEBookData, {});
inputMetadata = await doc.loaded.metadata
fingerprint = inputMetadata.identifier
} else {
reject("Unkown eBook format.")
}
var outputMetadata = {}
outputMetadata['fingerprint'] = fingerprint
outputMetadata['author'] = inputMetadata.info ? inputMetadata.info.Author : inputMetadata.creator
outputMetadata['fileType'] = "epub"
outputMetadata['Content-Type'] = "application/epub+zip"
outputMetadata['title'] = inputMetadata.info ? inputMetadata.info.Title : inputMetadata.title
outputMetadata['searchTitle'] = createSearchPattern(outputMetadata.title)
outputMetadata['searchAuthor'] = createSearchPattern(outputMetadata.author)
outputMetadata['isbn'] = guessISBNInIdentifier(outputMetadata.fingerprint)