aboutsummaryrefslogtreecommitdiff
path: root/node_modules/indent-string
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/indent-string')
-rw-r--r--node_modules/indent-string/index.js16
-rw-r--r--node_modules/indent-string/license20
-rw-r--r--node_modules/indent-string/package.json6
-rw-r--r--node_modules/indent-string/readme.md19
4 files changed, 33 insertions, 28 deletions
diff --git a/node_modules/indent-string/index.js b/node_modules/indent-string/index.js
index b6ab264ae..a48199ca5 100644
--- a/node_modules/indent-string/index.js
+++ b/node_modules/indent-string/index.js
@@ -1,6 +1,8 @@
'use strict';
-module.exports = (str, count, indent) => {
- indent = indent === undefined ? ' ' : indent;
+module.exports = (str, count, opts) => {
+ // Support older versions: use the third parameter as options.indent
+ // TODO: Remove the workaround in the next major version
+ const options = typeof opts === 'object' ? Object.assign({indent: ' '}, opts) : {indent: opts || ' '};
count = count === undefined ? 1 : count;
if (typeof str !== 'string') {
@@ -11,13 +13,15 @@ module.exports = (str, count, indent) => {
throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof count}\``);
}
- if (typeof indent !== 'string') {
- throw new TypeError(`Expected \`indent\` to be a \`string\`, got \`${typeof indent}\``);
+ if (typeof options.indent !== 'string') {
+ throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\``);
}
if (count === 0) {
return str;
}
- return str.replace(/^(?!\s*$)/mg, indent.repeat(count));
-};
+ const regex = options.includeEmptyLines ? /^/mg : /^(?!\s*$)/mg;
+ return str.replace(regex, options.indent.repeat(count));
+}
+;
diff --git a/node_modules/indent-string/license b/node_modules/indent-string/license
index 654d0bfe9..e7af2f771 100644
--- a/node_modules/indent-string/license
+++ b/node_modules/indent-string/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
Copyright (c) Sindre Sorhus <sindresorhus@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:
+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 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.
+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/node_modules/indent-string/package.json b/node_modules/indent-string/package.json
index d63feaa3a..e2a938b81 100644
--- a/node_modules/indent-string/package.json
+++ b/node_modules/indent-string/package.json
@@ -1,6 +1,6 @@
{
"name": "indent-string",
- "version": "3.1.0",
+ "version": "3.2.0",
"description": "Indent each line in a string",
"license": "MIT",
"repository": "sindresorhus/indent-string",
@@ -25,7 +25,9 @@
"pad",
"align",
"line",
- "text"
+ "text",
+ "each",
+ "every"
],
"devDependencies": {
"ava": "*",
diff --git a/node_modules/indent-string/readme.md b/node_modules/indent-string/readme.md
index bc4745600..d2592d73f 100644
--- a/node_modules/indent-string/readme.md
+++ b/node_modules/indent-string/readme.md
@@ -6,7 +6,7 @@
## Install
```
-$ npm install --save indent-string
+$ npm install indent-string
```
@@ -19,7 +19,7 @@ indentString('Unicorns\nRainbows', 4);
//=> ' Unicorns'
//=> ' Rainbows'
-indentString('Unicorns\nRainbows', 4, '♥');
+indentString('Unicorns\nRainbows', 4, {indent: '♥'});
//=> '♥♥♥♥Unicorns'
//=> '♥♥♥♥Rainbows'
```
@@ -27,7 +27,7 @@ indentString('Unicorns\nRainbows', 4, '♥');
## API
-### indentString(input, [count], [indent])
+### indentString(input, [count], [options])
#### input
@@ -42,13 +42,24 @@ Default: `1`
How many times you want `indent` repeated.
-#### indent
+#### options
+
+Type: `Object`<br>
+
+##### indent
Type: `string`<br>
Default: `' '`
String to use for the indent.
+##### includeEmptyLines
+
+Type: `boolean`<br>
+Default: `false`
+
+Also indent empty lines.
+
## Related