UNPKG

447 BPlain TextView Raw
1/** A simple class that extends string to allow for runtime checking of generated strings */
2export class SourceTemplate extends String {
3 /** @internal */
4 __source_template__ = true;
5
6 constructor(code: string) {
7 super(code.trim());
8 }
9
10 /** Checks if the provided string was created from a sour */
11 static match(this: void, str: unknown): str is SourceTemplate {
12 return (str as SourceTemplate).__source_template__ === true;
13 }
14}