MCPcopy Create free account
hub / github.com/Hashnode/starter-kit / addRule

Method addRule

packages/utils/renderer/highlight.js:530–538  ·  view source on GitHub ↗
(e, n)

Source from the content-addressed store, hash-verified

528 (this.position = 0);
529 }
530 addRule(e, n) {
531 (n.position = this.position++),
532 (this.matchIndexes[this.matchAt] = n),
533 this.regexes.push([n, e]),
534 (this.matchAt +=
535 (function (e) {
536 return RegExp(e.toString() + '|').exec('').length - 1;
537 })(e) + 1);
538 }
539 compile() {
540 0 === this.regexes.length && (this.exec = () => null);
541 const e = this.regexes.map((e) => e[1]);

Callers 1

getMatcherMethod · 0.95

Calls 1

execMethod · 0.45

Tested by

no test coverage detected