[Pkg-javascript-commits] [node-strip-indent] 01/04: Import Upstream version 2.0.0

Sruthi Chandran srud-guest at moszumanska.debian.org
Tue Oct 25 06:29:56 UTC 2016


This is an automated email from the git hooks/post-receive script.

srud-guest pushed a commit to branch master
in repository node-strip-indent.

commit 302d9091fdcc21b670a5204713d0d2d5a00371de
Author: Sruthi <srud at disroot.org>
Date:   Tue Oct 25 11:51:18 2016 +0530

    Import Upstream version 2.0.0
---
 .editorconfig  | 12 ++++++++++++
 .gitattributes |  1 +
 .gitignore     |  1 +
 .travis.yml    |  7 +++++++
 index.js       | 14 ++++++++++++++
 license        | 21 +++++++++++++++++++++
 package.json   | 41 +++++++++++++++++++++++++++++++++++++++++
 readme.md      | 44 ++++++++++++++++++++++++++++++++++++++++++++
 test.js        |  9 +++++++++
 9 files changed, 150 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..98a761d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[{package.json,*.yml}]
+indent_style = space
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..a78e23d
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,7 @@
+sudo: false
+language: node_js
+node_js:
+  - '5'
+  - '4'
+  - '0.12'
+  - '0.10'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..c90b265
--- /dev/null
+++ b/index.js
@@ -0,0 +1,14 @@
+'use strict';
+module.exports = str => {
+	const match = str.match(/^[ \t]*(?=\S)/gm);
+
+	if (!match) {
+		return str;
+	}
+
+	// TODO: use spread operator when targeting Node.js 6
+	const indent = Math.min.apply(Math, match.map(x => x.length)); // eslint-disable-line
+	const re = new RegExp(`^[ \\t]{${indent}}`, 'gm');
+
+	return indent > 0 ? str.replace(re, '') : str;
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..334dc8b
--- /dev/null
+++ b/package.json
@@ -0,0 +1,41 @@
+{
+  "name": "strip-indent",
+  "version": "2.0.0",
+  "description": "Strip leading whitespace from each line in a string",
+  "license": "MIT",
+  "repository": "sindresorhus/strip-indent",
+  "author": {
+    "name": "Sindre Sorhus",
+    "email": "sindresorhus at gmail.com",
+    "url": "sindresorhus.com"
+  },
+  "engines": {
+    "node": ">=4"
+  },
+  "scripts": {
+    "test": "xo && ava"
+  },
+  "files": [
+    "index.js"
+  ],
+  "keywords": [
+    "strip",
+    "indent",
+    "indentation",
+    "normalize",
+    "remove",
+    "delete",
+    "whitespace",
+    "space",
+    "tab",
+    "string",
+    "str"
+  ],
+  "devDependencies": {
+    "ava": "*",
+    "xo": "*"
+  },
+  "xo": {
+    "esnext": true
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..db979cd
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,44 @@
+# strip-indent [![Build Status](https://travis-ci.org/sindresorhus/strip-indent.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-indent)
+
+> Strip leading whitespace from each line in a string
+
+The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove.
+
+Useful for removing redundant indentation.
+
+
+## Install
+
+```
+$ npm install --save strip-indent
+```
+
+
+## Usage
+
+```js
+const stripIndent = require('strip-indent');
+
+const str = '\tunicorn\n\t\tcake';
+/*
+	unicorn
+		cake
+*/
+
+stripIndent('\tunicorn\n\t\tcake');
+/*
+unicorn
+	cake
+*/
+```
+
+
+## Related
+
+- [strip-indent-cli](https://github.com/sindresorhus/strip-indent-cli) - CLI for this module
+- [indent-string](https://github.com/sindresorhus/indent-string) - Indent each line in a string
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..40cbc04
--- /dev/null
+++ b/test.js
@@ -0,0 +1,9 @@
+import test from 'ava';
+import m from './';
+
+test(t => {
+	t.is(m('\nunicorn\n'), '\nunicorn\n');
+	t.is(m('\n  unicorn\n'), '\nunicorn\n');
+	t.is(m('\t\t<!doctype html>\n\t\t<html>\n\t\t\t<body>\n\n\n\n\t\t\t\t<h1>Hello world!</h1>\n\t\t\t</body>\n\t\t</html>'), '<!doctype html>\n<html>\n\t<body>\n\n\n\n\t\t<h1>Hello world!</h1>\n\t</body>\n</html>');
+	t.is(m('\n\t\n\t\tunicorn\n\n\n\n\t\t\tunicorn'), '\n\t\nunicorn\n\n\n\n\tunicorn', 'ignore whitespace only lines');
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-strip-indent.git



More information about the Pkg-javascript-commits mailing list