UNPKG

@ng-doc/builder

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

44 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NgDocCache = void 0; const core_1 = require("@ng-doc/core"); const helpers_1 = require("./helpers"); class NgDocCache { constructor(enabled) { this.enabled = enabled; } isCacheValid(cls) { return this.enabled && (0, helpers_1.isCacheValid)(cls.id, this.createCache(cls)); } cache(cls) { if (!this.enabled) { return; } (0, helpers_1.updateCache)(cls.id, this.createCache(cls)); } createCache(cls) { return (0, helpers_1.createCache)(undefined, this.getCachedPaths(cls), this.getCachedProperties(cls)); } getCachedPaths(cls) { return (0, core_1.asArray)(new Set((0, core_1.asArray)(cls.__cachedFiles?.values()) // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore .map((property) => cls[property]) .filter(core_1.isPresent) .flat()).values()); } getCachedProperties(cls) { const cachedProperties = {}; (0, core_1.asArray)(cls.__cachedProps?.keys()).forEach((property) => { const accessor = cls.__cachedProps?.get(property); if (accessor) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore cachedProperties[property] = accessor.set(cls[property]); } }); return cachedProperties; } } exports.NgDocCache = NgDocCache; //# sourceMappingURL=cache.js.map