mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Create ID lookup cache for manifest (#75)
This commit is contained in:
@@ -645,6 +645,7 @@ class Resources {
|
||||
item.properties = item.properties?.split(/\s/)
|
||||
return item
|
||||
})
|
||||
this.manifestById = new Map(this.manifest.map(item => [item.id, item]))
|
||||
this.spine = $$itemref
|
||||
.map(getAttributes('idref', 'id', 'linear', 'properties'))
|
||||
.map(item => (item.properties = item.properties?.split(/\s/), item))
|
||||
@@ -675,7 +676,7 @@ class Resources {
|
||||
this.cfis = CFI.fromElements($$itemref)
|
||||
}
|
||||
getItemByID(id) {
|
||||
return this.manifest.find(item => item.id === id)
|
||||
return this.manifestById.get(id)
|
||||
}
|
||||
getItemByHref(href) {
|
||||
return this.manifest.find(item => item.href === href)
|
||||
|
||||
Reference in New Issue
Block a user