Skip to content

Commit d5286ae

Browse files
committed
Create ID lookup cache for manifest
1 parent 19c6744 commit d5286ae

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

epub.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,10 @@ class Resources {
681681
this.cfis = CFI.fromElements($$itemref)
682682
}
683683
getItemByID(id) {
684-
return this.manifest.find(item => item.id === id)
684+
if (!this.manifestById) {
685+
this.manifestById = new Map(this.manifest.map(item => [item.id, item]))
686+
}
687+
return this.manifestById.get(id)
685688
}
686689
getItemByHref(href) {
687690
return this.manifest.find(item => item.href === href)

0 commit comments

Comments
 (0)