@awesome-fe/translate
Version:
Translation utils
27 lines • 790 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIndent = void 0;
const tab = '\t';
const space = ' ';
const spaceSize = 1;
const tabSize = 4;
// Gets indentation information for a line.
function getIndent(value) {
let index = 0;
let indent = 0;
let character = value.charAt(index);
const stops = {};
let size;
while (character === tab || character === space) {
size = character === tab ? tabSize : spaceSize;
indent += size;
if (size > 1) {
indent = Math.floor(indent / size) * size;
}
stops[indent] = index;
character = value.charAt(++index);
}
return { indent: indent, stops: stops };
}
exports.getIndent = getIndent;
//# sourceMappingURL=get-indent.js.map