aboutsummaryrefslogtreecommitdiff
path: root/node_modules/indent-string/index.js
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/index.js
parentc9f5ac8e763eda19aa0564179300cfff76785435 (diff)
node_modules, clean up package.json
Diffstat (limited to 'node_modules/indent-string/index.js')
-rw-r--r--node_modules/indent-string/index.js21
1 files changed, 12 insertions, 9 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));
};