Created
April 5, 2022 17:43
-
-
Save ntns/97d2c79320c24a0626a5da306dada1dd to your computer and use it in GitHub Desktop.
tagged template strings - join maps like jsx does
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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