Skip to content

Instantly share code, notes, and snippets.

@ntns
Created April 5, 2022 17:43
Show Gist options
  • Save ntns/97d2c79320c24a0626a5da306dada1dd to your computer and use it in GitHub Desktop.
Save ntns/97d2c79320c24a0626a5da306dada1dd to your computer and use it in GitHub Desktop.
tagged template strings - join maps like jsx does
export function j(strings: TemplateStringsArray, ...values: any) {
return strings
.map((string: string, i: number) => {
return Array.isArray(values[i])
? string + values[i].join("")
: string + (values[i] || "");
})
.join("");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment