Skip to content

Instantly share code, notes, and snippets.

@regiskuckaertz
Created August 4, 2017 12:21
Show Gist options
  • Save regiskuckaertz/c4b88933eb6b38907f39e9157ec71c8f to your computer and use it in GitHub Desktop.
Save regiskuckaertz/c4b88933eb6b38907f39e9157ec71c8f to your computer and use it in GitHub Desktop.
Scala's stripMargin
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