@egodigital/nef
Version:
Managed Extensibility Framework like library written for Node.js
49 lines • 1.9 kB
JavaScript
;
/**
* This file is part of the @egodigital/nef distribution.
* Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/)
*
* @egodigital/nef is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, version 3.
*
* @egodigital/nef is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FilteredCatalog = void 0;
const CatalogBase_1 = require("./CatalogBase");
const util_1 = require("../util");
/**
* A catalog, which filters the exports of a base catalog.
*/
class FilteredCatalog extends CatalogBase_1.CatalogBase {
/**
* Initializes a new instance of that class.
*
* @param {TCatalog} catalog The underlying (base) catalog.
* @param {FilteredCatalogPredicate<TCatalog>} predicate The predicate to use.
*/
constructor(catalog, predicate) {
super();
this.catalog = catalog;
this.predicate = predicate;
}
/** @inheritdoc */
async getClasses() {
return (await this.catalog.getClasses())
.filter((cls, i) => util_1.toBooleanSafe(this.predicate(cls, i, this.catalog)));
}
/** @inheritdoc */
getClassesSync() {
return this.catalog.getClassesSync()
.filter((cls, i) => util_1.toBooleanSafe(this.predicate(cls, i, this.catalog)));
}
}
exports.FilteredCatalog = FilteredCatalog;
//# sourceMappingURL=FilteredCatalog.js.map