Front end of the Slack clone application.

index.js 320B

1234567891011121314151617
  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. };