Add destroy method

Which revokes all blob URLs and removes the element from document.
This commit is contained in:
John Factotum
2023-05-09 14:02:07 +08:00
parent a817932b08
commit 5da3be5200
7 changed files with 45 additions and 5 deletions
+4
View File
@@ -36,5 +36,9 @@ export const makeComicBook = ({ entries, loadBlob, getSize }, file) => {
book.resolveHref = href => ({ index: book.sections.findIndex(s => s.id === href) })
book.splitTOCHref = href => [href, null]
book.getTOCFragment = doc => doc.documentElement
book.destroy = () => {
for (const arr of urls.values())
for (const url of arr) URL.revokeObjectURL(url)
}
return book
}