blob: 8f8f4f444c82a66faf19f3ae256ae43055ee78cd [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2module.exports = function (str) {
3 var match = str.match(/^[ \t]*(?=\S)/gm);
4
5 if (!match) {
6 return str;
7 }
8
9 var indent = Math.min.apply(Math, match.map(function (el) {
10 return el.length;
11 }));
12
13 var re = new RegExp('^[ \\t]{' + indent + '}', 'gm');
14
15 return indent > 0 ? str.replace(re, '') : str;
16};