Created
February 5, 2020 20:55
-
-
Save michal-wrzosek/7edf691beab2e218c47e5f428d2129a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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