@visulima/string
Version:
Functions for manipulating strings.
2 lines (1 loc) • 572 B
JavaScript
function i(e,t=1,r={}){const{indent:o=" ",includeEmptyLines:n=!1}=r;if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if(typeof t!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if(t<0)throw new RangeError(`Expected \`count\` to be at least 0, got \`${t}\``);if(typeof o!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof o}\``);if(t===0)return e;const p=n?/^/gm:/^(?!\s*$)/gm;return e.replace(p,o.repeat(t))}export{i as default};