tiny-types
Version:
A tiny library that brings Tiny Types to JavaScript and TypeScript
21 lines • 609 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PatternMatcher = void 0;
const rules_1 = require("./rules");
/**
* @access private
*/
class PatternMatcher {
value;
rules;
constructor(value, rules = []) {
this.value = value;
this.rules = rules;
}
else(transformation) {
const matching_rule = this.rules.find(m => m.matches(this.value));
return (matching_rule || new rules_1.MatchesAnything(transformation)).execute(this.value);
}
}
exports.PatternMatcher = PatternMatcher;
//# sourceMappingURL=PatternMatcher.js.map