Skip to content

md-vanilla/js-trim-multiline-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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

  return stringConcatenation;
}

After:

const 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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published