Created
August 4, 2017 12:21
-
-
Save regiskuckaertz/c4b88933eb6b38907f39e9157ec71c8f to your computer and use it in GitHub Desktop.
Scala's stripMargin
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
function stripMargin(sts, ...vals) { | |
let tts = sts[0]; | |
if( vals.length ) { | |
tts = sts.reduce((s, i) => s + vals[i], ''); | |
} | |
return tts.split('\n') | |
.map(s => s.trimLeft().startsWith('|') | |
? s.trimLeft().substr(1) | |
: s) | |
.join('\n'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment