65 lines
5.0 KiB
JavaScript
65 lines
5.0 KiB
JavaScript
"use strict";
|
|
var splitString = function (stringArg) {
|
|
var resultArray = stringArg.split("\n");
|
|
return cleanStringArray(resultArray);
|
|
};
|
|
var joinString = function (stringArrayArg) {
|
|
var resultString = "";
|
|
for (var _i = 0, stringArrayArg_1 = stringArrayArg; _i < stringArrayArg_1.length; _i++) {
|
|
var line = stringArrayArg_1[_i];
|
|
resultString = resultString + line + "\n";
|
|
}
|
|
;
|
|
return resultString;
|
|
};
|
|
var cleanStringArray = function (stringArrayArg) {
|
|
var testRegex = /^[\s]*$/;
|
|
if (testRegex.test(stringArrayArg[0])) {
|
|
stringArrayArg.shift();
|
|
}
|
|
if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
|
|
stringArrayArg.pop();
|
|
}
|
|
;
|
|
return stringArrayArg;
|
|
};
|
|
exports.indent = function (stringArg, spaceAmount) {
|
|
var resultString;
|
|
return resultString;
|
|
};
|
|
exports.indentWithPrefix = function (stringArg, prefixArg) {
|
|
var resultString;
|
|
var stringArray = splitString(stringArg);
|
|
var resultArray = [];
|
|
for (var _i = 0, stringArray_1 = stringArray; _i < stringArray_1.length; _i++) {
|
|
var stringItem = stringArray_1[_i];
|
|
resultArray.push(prefixArg + stringItem);
|
|
}
|
|
;
|
|
resultString = joinString(resultArray);
|
|
return resultString;
|
|
};
|
|
exports.normalizeIndent = function (stringArg) {
|
|
var resultString;
|
|
var splitStringArray = splitString(stringArg);
|
|
var minCommonLeftOffset;
|
|
var deIndentRegex = /^(\s*)/;
|
|
for (var _i = 0, splitStringArray_1 = splitStringArray; _i < splitStringArray_1.length; _i++) {
|
|
var stringItem = splitStringArray_1[_i];
|
|
var offsetString = deIndentRegex.exec(stringItem)[1];
|
|
if (typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset) {
|
|
minCommonLeftOffset = offsetString.length;
|
|
}
|
|
;
|
|
}
|
|
;
|
|
var resultSplitStringArray = [];
|
|
for (var _a = 0, splitStringArray_2 = splitStringArray; _a < splitStringArray_2.length; _a++) {
|
|
var stringItem = splitStringArray_2[_a];
|
|
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
|
|
}
|
|
;
|
|
resultString = joinString(resultSplitStringArray);
|
|
return resultString;
|
|
};
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuaW5kZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuaW5kZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxJQUFJLFdBQVcsR0FBRyxVQUFDLFNBQWdCO0lBQy9CLElBQUksV0FBVyxHQUFHLFNBQVMsQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDeEMsTUFBTSxDQUFDLGdCQUFnQixDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ3pDLENBQUMsQ0FBQztBQUVGLElBQUksVUFBVSxHQUFHLFVBQUMsY0FBdUI7SUFDckMsSUFBSSxZQUFZLEdBQVUsRUFBRSxDQUFDO0lBQzdCLEdBQUcsQ0FBQSxDQUFhLFVBQWMsRUFBZCxpQ0FBYyxFQUFkLDRCQUFjLEVBQWQsSUFBYyxDQUFDO1FBQTNCLElBQUksSUFBSSx1QkFBQTtRQUNSLFlBQVksR0FBRyxZQUFZLEdBQUcsSUFBSSxHQUFHLElBQUksQ0FBQztLQUM3QztJQUFBLENBQUM7SUFDRixNQUFNLENBQUMsWUFBWSxDQUFDO0FBQ3hCLENBQUMsQ0FBQztBQUVGLElBQUksZ0JBQWdCLEdBQUcsVUFBQyxjQUF1QjtJQUMzQyxJQUFJLFNBQVMsR0FBRyxTQUFTLENBQUM7SUFDMUIsRUFBRSxDQUFBLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxjQUFjLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUF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