From b8d9aa999e464816c6cfb14acd1ad0f5d1e335aa Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Mon, 2 Sep 2024 16:43:41 -0700 Subject: [PATCH] Remove template display name --- src/index.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 49f0ed5..21fbb72 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ export type Template = (data: T) => string; /** * Stringify a template into a function. */ -export function compile(value: string, displayName = "template") { +export function compile(value: string) { let result = QUOTE_CHAR; for (let i = 0; i < value.length; i++) { const char = value[i]; @@ -50,16 +50,13 @@ export function compile(value: string, displayName = "template") { } result += QUOTE_CHAR; - return `function ${displayName}(${INPUT_VAR_NAME}) { return ${result}; }`; + return `function (${INPUT_VAR_NAME}) { return ${result}; }`; } /** * Fast and simple string templates. */ -export function template( - value: string, - displayName?: string -) { - const body = compile(value, displayName); +export function template(value: string) { + const body = compile(value); return new Function(`return (${body});`)() as Template; }