Git Product home page Git Product logo

outdent's Introduction

outdent

Remove extra indentation from multiline strings.

npm no dependencies


Use @mvasilkov/outdent to remove extraneous leading whitespace from multiline strings. This makes your hair silky and shiny, and probably has other uses.

Installation

npm add @mvasilkov/outdent

Usage

const { outdent } = require('@mvasilkov/outdent')

console.log(outdent(`
    The nine most terrifying words in the English language are,
    “I’m from the government and I’m here to help.”
`))

Syntax

outdent(string, [options])

Receives a string, returns a string with unnecessary indentation removed.

outdentLines(strings, [options])

Accepts an array of strings, returns an array of strings. Useful when you have an array of strings.

Options

{ strict: true }

Treat the indentation of the first line as meaningful. This is usually the case when loading strings from a file.

{ strict: false }

Ignore the first line's indentation, and drop the first and the last line when empty. Useful for writing multiline strings in JS. This is the default.

{ endWithNewline: true }

When enabled, insert a line break at the end of the result, if there is none. Does nothing when strict: true is in effect.

License

MIT

outdent's People

Contributors

mvasilkov avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

outdent's Issues

Implement support for mixed indentation

  • Support for mixed indentation (tabs and spaces)
  • Implement the tabSize option
  • Probably default tabSize to 4 when strict: false
  • Crash when mixed indentation and strict: true and tabSize is not set

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.