We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b6bf740 commit 823fd7cCopy full SHA for 823fd7c
interpreter.ts
@@ -7,12 +7,19 @@ import type {
7
} from "./types.ts";
8
9
export class Interpreter implements Runtime {
10
+ _cache: Map<string, AstTemplate> = new Map();
11
+
12
execute(
13
text: string,
14
parameters: FormatParameters,
15
decorateValue?: (value: FormatParameterValue) => unknown,
16
): string {
- return this.executeAst(parse(text), parameters, decorateValue);
17
+ let ast = this._cache.get(text);
18
+ if (!ast) {
19
+ ast = parse(text);
20
+ this._cache.set(text, ast);
21
+ }
22
+ return this.executeAst(ast, parameters, decorateValue);
23
}
24
25
executeAst(
0 commit comments