UNPKG

epubavocado

Version:

I am an EPUB object model aspiring to be standards compliant.

29 lines (28 loc) 1.22 kB
import { Entity } from '../mixins/entity.js'; import { ID } from './mixins/id.js'; import { toArray } from '../../util.js'; import { ManifestItem } from './manifest-item.js'; import { idFilter, attributeFilter, anyPropertiesFilter, allPropertiesFilter, } from './util.js'; export class Manifest extends ID(Entity) { item({ id, href, anyProperties, allProperties, onlyProperties, } = {}) { return this.items({ ids: id ? [id] : [], href, anyProperties, allProperties, onlyProperties, })[0]; } items({ ids, href, anyProperties, allProperties, onlyProperties, } = {}) { var _a; if (onlyProperties) { return (_a = this.items({ ids: ids, anyProperties, allProperties: onlyProperties, })) === null || _a === void 0 ? void 0 : _a.filter((item) => toArray(item.properties()).length === onlyProperties.length); } const expression = `./opf:item${idFilter(ids)}${attributeFilter('@href', href)}${anyPropertiesFilter(anyProperties)}${allPropertiesFilter(allProperties)}`; return this._resolveAll(expression, ManifestItem); } }