Created
January 16, 2017 13:26
-
-
Save DrummerHead/ff1495237bb654c507ed4b51e4e1d358 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
// Clap text generator | |
// =================== | |
// ## Function | |
// | |
const clapText = (text, { uppercase = false, tight = false } = {}) => { | |
const space = tight ? '' : ' '; | |
const newText = uppercase ? text.toUpperCase() : text; | |
return newText.replace(/\s/g, `${space}๐${space}`); | |
} | |
// ## Usage Examples | |
// | |
console.log(clapText('Bright vixens jump; dozy fowl quack. Vexed nymphs go for quick waltz job.')) | |
// > Bright ๐ vixens ๐ jump; ๐ dozy ๐ fowl ๐ quack. ๐ Vexed ๐ nymphs ๐ go ๐ for ๐ quick ๐ waltz ๐ job. | |
// ### Passing options | |
console.log(clapText('Junk MTV quiz graced by fox whelps. Bawds jog, flick quartz, vex nymphs.', { uppercase: true })) | |
// > JUNK ๐ MTV ๐ QUIZ ๐ GRACED ๐ BY ๐ FOX ๐ WHELPS. ๐ BAWDS ๐ JOG, ๐ FLICK ๐ QUARTZ, ๐ VEX ๐ NYMPHS. | |
console.log(clapText('Hick dwarves jam blitzing foxy quip. Fox dwarves chop my talking quiz job.', { tight: true })) | |
// > Hick๐dwarves๐jam๐blitzing๐foxy๐quip.๐Fox๐dwarves๐chop๐my๐talking๐quiz๐job. | |
console.log(clapText('How quickly daft jumping zebras vex. Two driven jocks help fax my big quiz.', { uppercase: true, tight: true })) | |
// > HOW๐QUICKLY๐DAFT๐JUMPING๐ZEBRAS๐VEX.๐TWO๐DRIVEN๐JOCKS๐HELP๐FAX๐MY๐BIG๐QUIZ. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment