browserify-ftw
Version:
Upgrade your app from requireJS AMD to commonJS module format via an automated refactor step in order to browserify it.
28 lines (22 loc) • 507 B
JavaScript
;
function spaces(indent) {
for (var i = 1, s = ' '; i < indent; i++) s += ' ';
return s;
}
function indentRegex(indent) {
return new RegExp('^' + spaces(indent));
}
function fixLineIndent(line, regex) {
return line.replace(regex, '');
}
function tabLeft(code, tabsize) {
var regex = indentRegex(tabsize);
return code
.split('\n')
.map(function (line) { return line.replace(regex, ''); })
.join('\n');
}
module.exports = {
tabLeft: tabLeft
, spaces: spaces
};