aboutsummaryrefslogtreecommitdiff
path: root/node_modules/indent-string
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-27 17:36:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-27 17:36:13 +0200
commit5f466137ad6ac596600e3ff53c9b786815398445 (patch)
treef914c221874f0b16bf3def7ac01d59d1a99a3b0b /node_modules/indent-string
parentc9f5ac8e763eda19aa0564179300cfff76785435 (diff)
node_modules, clean up package.json
Diffstat (limited to 'node_modules/indent-string')
-rw-r--r--node_modules/indent-string/index.js21
-rw-r--r--node_modules/indent-string/package.json12
-rw-r--r--node_modules/indent-string/readme.md37
3 files changed, 37 insertions, 33 deletions
diff --git a/node_modules/indent-string/index.js b/node_modules/indent-string/index.js
index 4a21687b2..b6ab264ae 100644
--- a/node_modules/indent-string/index.js
+++ b/node_modules/indent-string/index.js
@@ -1,20 +1,23 @@
'use strict';
-var repeating = require('repeating');
+module.exports = (str, count, indent) => {
+ indent = indent === undefined ? ' ' : indent;
+ count = count === undefined ? 1 : count;
-module.exports = function (str, indent, count) {
- if (typeof str !== 'string' || typeof indent !== 'string') {
- throw new TypeError('`string` and `indent` should be strings');
+ if (typeof str !== 'string') {
+ throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof str}\``);
}
- if (count != null && typeof count !== 'number') {
- throw new TypeError('`count` should be a number');
+ if (typeof count !== 'number') {
+ 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 (count === 0) {
return str;
}
- indent = count > 1 ? repeating(indent, count) : indent;
-
- return str.replace(/^(?!\s*$)/mg, indent);
+ return str.replace(/^(?!\s*$)/mg, indent.repeat(count));
};
diff --git a/node_modules/indent-string/package.json b/node_modules/indent-string/package.json
index 0e7d28cb2..d63feaa3a 100644
--- a/node_modules/indent-string/package.json
+++ b/node_modules/indent-string/package.json
@@ -1,6 +1,6 @@
{
"name": "indent-string",
- "version": "2.1.0",
+ "version": "3.1.0",
"description": "Indent each line in a string",
"license": "MIT",
"repository": "sindresorhus/indent-string",
@@ -10,10 +10,10 @@
"url": "sindresorhus.com"
},
"engines": {
- "node": ">=0.10.0"
+ "node": ">=4"
},
"scripts": {
- "test": "mocha"
+ "test": "xo && ava"
},
"files": [
"index.js"
@@ -27,10 +27,8 @@
"line",
"text"
],
- "dependencies": {
- "repeating": "^2.0.0"
- },
"devDependencies": {
- "mocha": "*"
+ "ava": "*",
+ "xo": "*"
}
}
diff --git a/node_modules/indent-string/readme.md b/node_modules/indent-string/readme.md
index 89f14acd4..bc4745600 100644
--- a/node_modules/indent-string/readme.md
+++ b/node_modules/indent-string/readme.md
@@ -13,39 +13,42 @@ $ npm install --save indent-string
## Usage
```js
-var indentString = require('indent-string');
+const indentString = require('indent-string');
-indentString('Unicorns\nRainbows', '♥', 4);
-//=> ♥♥♥♥Unicorns
-//=> ♥♥♥♥Rainbows
+indentString('Unicorns\nRainbows', 4);
+//=> ' Unicorns'
+//=> ' Rainbows'
+
+indentString('Unicorns\nRainbows', 4, '♥');
+//=> '♥♥♥♥Unicorns'
+//=> '♥♥♥♥Rainbows'
```
## API
-### indentString(string, indent, count)
-
-#### string
-
-**Required**
-Type: `string`
-
-The string you want to indent.
+### indentString(input, [count], [indent])
-#### indent
+#### input
-**Required**
Type: `string`
-The string to use for the indent.
+String you want to indent.
#### count
-Type: `number`
+Type: `number`<br>
Default: `1`
How many times you want `indent` repeated.
+#### indent
+
+Type: `string`<br>
+Default: `' '`
+
+String to use for the indent.
+
## Related
@@ -55,4 +58,4 @@ How many times you want `indent` repeated.
## License
-MIT © [Sindre Sorhus](http://sindresorhus.com)
+MIT © [Sindre Sorhus](https://sindresorhus.com)