UNPKG

textlint

Version:

The pluggable linting tool for text and markdown.

50 lines 986 B
// LICENSE : MIT "use strict"; /** * @typedef {{key: Function}} RulesObject */ export 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; } } //# sourceMappingURL=rule-map.js.map