You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 320B

12345678910111213141516
  1. 'use strict';
  2. module.exports = function (str) {
  3. var match = str.match(/^[ \t]*(?=\S)/gm);
  4. if (!match) {
  5. return str;
  6. }
  7. var indent = Math.min.apply(Math, match.map(function (el) {
  8. return el.length;
  9. }));
  10. var re = new RegExp('^[ \\t]{' + indent + '}', 'gm');
  11. return indent > 0 ? str.replace(re, '') : str;
  12. };