1.0.8 • Published 5 years ago

js-trim-multiline-string v1.0.8

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

js-trim-multiline-string Build Status

multiline strings are a pain in javascript.

the most readable multiline string is as follows:

Expected Result:

"
this
is
a
multiline
string
"

Before:

def multilineStringExample() {
  const  stringConcatenation  = '' +
    'this ' +
    'is' +
    'a' +
    'multiline' +
    'string' +
    '';

  return stringConcatenation;
}

After:

def multilineStringExample() {
  const taggedTemplate = mtrim `
    this
    is
    a
    multiline
    string
  `
  return taggedTemplate
}

Install

$ 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)
)

Related

  • multiline - Multiline string using anonymous function, and function call.
  • trim-newlines - Similar to String#trim() but removes only newlines
  • trim-right - Similar to String#trim() but removes only whitespace on the right
  • trim-off-newlines - Similar to String#trim() but removes only newlines

License

MIT © michael_dimmitt

Projects Using mtrim:

https://github.com/MichaelDimmitt/simp-js_term/blob/master/terminal.test.js

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago