Sha256: 8905c488b758285ca27105613edb72b179e30740d59bd74c627d1de89293746b
Contents?: true
Size: 610 Bytes
Versions: 19
Compression:
Stored size: 610 Bytes
Contents
var makeString = require('./helper/makeString'); function getIndent(str) { var matches = str.match(/^[\s\\t]*/gm); var indent = matches[0].length; for (var i = 1; i < matches.length; i++) { indent = Math.min(matches[i].length, indent); } return indent; } module.exports = function dedent(str, pattern) { str = makeString(str); var indent = getIndent(str); var reg; if (indent === 0) return str; if (typeof pattern === 'string') { reg = new RegExp('^' + pattern, 'gm'); } else { reg = new RegExp('^[ \\t]{' + indent + '}', 'gm'); } return str.replace(reg, ''); };
Version data entries
19 entries across 19 versions & 1 rubygems