123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- "use strict";
- const debug = require("debug")("eslint:rules");
- class LazyLoadingRuleMap extends Map {
-
- constructor(loaders) {
- let remaining = loaders.length;
- super(
- debug.enabled
- ? loaders.map(([ruleId, load]) => {
- let cache = null;
- return [
- ruleId,
- () => {
- if (!cache) {
- debug("Loading rule %o (remaining=%d)", ruleId, --remaining);
- cache = load();
- }
- return cache;
- }
- ];
- })
- : loaders
- );
-
- Object.defineProperty(LazyLoadingRuleMap.prototype, "set", {
- configurable: true,
- value: void 0
- });
- }
-
- get(ruleId) {
- const load = super.get(ruleId);
- return load && load();
- }
-
- *values() {
- for (const load of super.values()) {
- yield load();
- }
- }
-
- *entries() {
- for (const [ruleId, load] of super.entries()) {
- yield [ruleId, load()];
- }
- }
-
- forEach(callbackFn, thisArg) {
- for (const [ruleId, load] of super.entries()) {
- callbackFn.call(thisArg, load(), ruleId, this);
- }
- }
- }
- Object.defineProperties(LazyLoadingRuleMap.prototype, {
- clear: { configurable: true, value: void 0 },
- delete: { configurable: true, value: void 0 },
- [Symbol.iterator]: {
- configurable: true,
- writable: true,
- value: LazyLoadingRuleMap.prototype.entries
- }
- });
- module.exports = { LazyLoadingRuleMap };
|