multiline strings are a pain in javascript.
the most readable multiline string is as follows:
"
this
is
a
multiline
string
"
const multilineStringExample = () => {
const stringConcatenation = '' +
'this ' +
'is' +
'a' +
'multiline' +
'string' +
'';
return stringConcatenation;
}
const multilineStringExample = () => {
const taggedTemplate = mtrim `
this
is
a
multiline
string
`
return taggedTemplate
}
$ npm install --save trim-multiline-string
FullUsage, (Use the library as a Function, Tagged Template, Prototype Function), If Indent present keep Indent.!
const { mtrim } = require('trim-multiline-string');
console.log(
mtrim(str),
mtrim(`str`),
mtrim`
check it out!
`,
mtrim
`check it out!`,
`str`.mtrim()
`
Keep Indent
Implementation
By Passing Number!
`.mtrim(3)
)
multiline
- Multiline string using anonymous function, and function call.trim-newlines
- Similar toString#trim()
but removes only newlinestrim-right
- Similar toString#trim()
but removes only whitespace on the righttrim-off-newlines
- Similar toString#trim()
but removes only newlines
MIT © michael_dimmitt
https://github.com/MichaelDimmitt/simp-js_term/blob/master/terminal.test.js