UNPKG

textlint

Version:

The pluggable linting tool for natural language.

53 lines 1.09 kB
// LICENSE : MIT "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RuleMap = void 0; /** * @typedef {{key: Function}} RulesObject */ class RuleMap extends Map { /** * has rule at least one > 0 * @returns {boolean} */ hasRuleAtLeastOne() { return this.size > 0; } getAllRuleNames() { return this.keys(); } getRule(ruleKey) { return this.get(ruleKey); } /** * @returns {RulesObject} */ getAllRules() { return this.toJSON(); } isDefinedRule(ruleKey) { return this.has(ruleKey); } /** * @param {string} ruleKey * @param ruleHandler */ defineRule(ruleKey, ruleHandler) { this.set(ruleKey, ruleHandler); } /** * reset defined rules */ resetRules() { this.clear(); } toJSON() { const object = {}; this.forEach((value, key) => { object[key] = value; }); return object; } } exports.RuleMap = RuleMap; //# sourceMappingURL=rule-map.js.map