1.0.0 • Published 7 years ago

normalize-indent v1.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

normalize-indent

This module uses a RegEx based replacement to normalize the indentation of a single- or multiline string.
The indentation is recognized with the first line and then removed from the beginning of any following line.

Please notice that the function may produce unexpected results if the indentation is not unified!

Setup

Node.js

$ npm install --save normalize-indent

const normalizeIndent = require('normalize-indent');

Bower

$ bower install normalize-indent

<script src="bower_components/normalize-indent/lib/normalize-indent.js" charset="utf-8" />

Direct link

The modules can also be accessed directly through GitHub Raw Usercontent.

GitHub Raw: https://raw.githubusercontent.com/MCStreetguy/normalize-indent/master/lib/normalize-indent.js
Shortened: https://goo.gl/BjqiMj

Usage

var normalized = normalizeIndent('\t\t\tconsole.log("Hello World")\n\t\t\tconsole.log("Foobar")');

=>

normalized: "console.log(\"Hello World\")\\nconsole.log(\"Foobar\")"