.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / node_modules / strip-indent / index.js
1 'use strict';
2 module.exports = str => {
3         const match = str.match(/^[ \t]*(?=\S)/gm);
4
5         if (!match) {
6                 return str;
7         }
8
9         // TODO: use spread operator when targeting Node.js 6
10         const indent = Math.min.apply(Math, match.map(x => x.length)); // eslint-disable-line
11         const re = new RegExp(`^[ \\t]{${indent}}`, 'gm');
12
13         return indent > 0 ? str.replace(re, '') : str;
14 };