From 5f466137ad6ac596600e3ff53c9b786815398445 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 27 May 2017 17:36:13 +0200 Subject: node_modules, clean up package.json --- node_modules/indent-string/index.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'node_modules/indent-string/index.js') 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)); }; -- cgit v1.2.3