.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / node_modules / indent-string / index.js
1 'use strict';
2 module.exports = (str, count, opts) => {
3         // Support older versions: use the third parameter as options.indent
4         // TODO: Remove the workaround in the next major version
5         const options = typeof opts === 'object' ? Object.assign({indent: ' '}, opts) : {indent: opts || ' '};
6         count = count === undefined ? 1 : count;
7
8         if (typeof str !== 'string') {
9                 throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof str}\``);
10         }
11
12         if (typeof count !== 'number') {
13                 throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof count}\``);
14         }
15
16         if (typeof options.indent !== 'string') {
17                 throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\``);
18         }
19
20         if (count === 0) {
21                 return str;
22         }
23
24         const regex = options.includeEmptyLines ? /^/mg : /^(?!\s*$)/mg;
25         return str.replace(regex, options.indent.repeat(count));
26 }
27 ;