epubavocado
Version:
I am an EPUB object model aspiring to be standards compliant.
53 lines (52 loc) • 2.56 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Manifest = void 0;
var entity_js_1 = require("../mixins/entity.js");
var id_js_1 = require("./mixins/id.js");
var util_js_1 = require("../../util.js");
var manifest_item_js_1 = require("./manifest-item.js");
var util_js_2 = require("./util.js");
var Manifest = /** @class */ (function (_super) {
__extends(Manifest, _super);
function Manifest() {
return _super !== null && _super.apply(this, arguments) || this;
}
Manifest.prototype.item = function (_a) {
var _b = _a === void 0 ? {} : _a, id = _b.id, href = _b.href, anyProperties = _b.anyProperties, allProperties = _b.allProperties, onlyProperties = _b.onlyProperties;
return this.items({
ids: id ? [id] : [],
href: href,
anyProperties: anyProperties,
allProperties: allProperties,
onlyProperties: onlyProperties,
})[0];
};
Manifest.prototype.items = function (_a) {
var _b;
var _c = _a === void 0 ? {} : _a, ids = _c.ids, href = _c.href, anyProperties = _c.anyProperties, allProperties = _c.allProperties, onlyProperties = _c.onlyProperties;
if (onlyProperties) {
return (_b = this.items({
ids: ids,
anyProperties: anyProperties,
allProperties: onlyProperties,
})) === null || _b === void 0 ? void 0 : _b.filter(function (item) { return util_js_1.toArray(item.properties()).length === onlyProperties.length; });
}
var expression = "./opf:item" + util_js_2.idFilter(ids) + util_js_2.attributeFilter('@href', href) + util_js_2.anyPropertiesFilter(anyProperties) + util_js_2.allPropertiesFilter(allProperties);
return this._resolveAll(expression, manifest_item_js_1.ManifestItem);
};
return Manifest;
}(id_js_1.ID(entity_js_1.Entity)));
exports.Manifest = Manifest;