diff options
Diffstat (limited to 'node_modules/indent-string/index.js')
-rw-r--r-- | node_modules/indent-string/index.js | 21 |
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)); }; |