Skip to content
This repository has been archived by the owner on May 31, 2022. It is now read-only.
/ multili Public archive

Function to remove indentation in multi-lines template literals (string) based on the shortest indented line.

License

Notifications You must be signed in to change notification settings

MoOx/multili

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multili

Unix Build status Code Coverage Version

Repo on GitHub Repo on GitLab Repo on BitBucket

Function to remove indentation in multi-lines template literals (string) based on the shortest indented line.

Installation

$ npm install multili

Usage

import multili from "multili"

multili(
  `
      This is a
        multi-lines
          string
  `
)

// Will produce
/*
This is a
  multi-lines
    string
*/

multili(`
  This is a
  multi-lines
    string
`)

// Will produce
/*
This is a
multi-lines
  string
*/


multili(`
      This is a
  multi-lines
    string
`)

// Will produce
/*
    This is a
multi-lines
  string
*/

You can also pass an array of lines instead of a string; in this case, the return value will also be an array.

multili([
  "        This is a",
  "          milti-line",
  "            string",
])

// Will produce
/*
[
  "This is a",
  "  milti-line",
  "    string",
]
*/

CONTRIBUTING

  • ⇄ Pull/Merge requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull/Merge requests must be accompanied by passing automated tests ($ npm test).

About

Function to remove indentation in multi-lines template literals (string) based on the shortest indented line.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages