Skip to content

Instantly share code, notes, and snippets.

@michal-wrzosek
Created February 5, 2020 20:55
Show Gist options
  • Save michal-wrzosek/7edf691beab2e218c47e5f428d2129a1 to your computer and use it in GitHub Desktop.
Save michal-wrzosek/7edf691beab2e218c47e5f428d2129a1 to your computer and use it in GitHub Desktop.
function cntl(template: TemplateStringsArray, ...templateElements: any[]) {
return template
.reduce((sum, n, index) => {
const templateElement = templateElements[index];
if (typeof templateElement === 'string') {
return `${sum}${n}${templateElement}`;
}
return `${sum}${n}`;
}, '')
.trim()
.replace(/\s{2,}/g, ' ');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment