Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getInfo(filePath, callback) {
// parameter validation
if (!filePath || typeof filePath !== 'string') {
return;
}
// create a key from path
const key = genrateKey(filePath);
// file load on file protocol
const uri = fileUrl(filePath);
const book = new Book(uri);
book.ready
.then(() => {
return book.locations.generate();
})
.then(locations => {
const meta = book.package.metadata;
const info = {
id: key,
title: meta.title,
author: meta.creator,
publisher: meta.publisher,
path: uri,
bookmarks: [],
highlights: [],
mounted() {
const { id } = this.$route.params;
this.info = this.$db.get(id);
this.toc = this.info.toc;
this.info.lastOpen = new Date().getTime();
this.buble = this.$refs.bubleMenu
this.book = new Book(this.info.path);
this._flattenedToc = (function flatten(items) {
return [].concat(...items.map(item => [item].concat(...flatten(item.children))));
})(this.toc);
this._flattenedToc.sort((a,b)=>{
return a.percentage - b.percentage;
})
this.rendition = new Rendition(this.book, {
width: '100%',
height: '100%',
});
this.rendition.on('rendered', (e, iframe) => {
clickListener(iframe.document, this.rendition, this.flipPage);