MCPcopy
hub / github.com/jestjs/jest / makeTemplate

Function makeTemplate

e2e/Utils.ts:97–104  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

95
96export const makeTemplate =
97 (str: string): ((values?: Array<string>) => string) =>
98 (values = []) =>
99 str.replaceAll(/\$(\d+)/g, (_match, number) => {
100 if (!Array.isArray(values)) {
101 throw new TypeError('Array of values must be passed to the template.');
102 }
103 return values[number - 1];
104 });
105
106export const cleanup = (directory: string) => {
107 try {

Calls

no outgoing calls

Tested by

no test coverage detected