57 lines
4.4 KiB
JavaScript
57 lines
4.4 KiB
JavaScript
"use strict";
|
|
var splitString = function (stringArg) {
|
|
return stringArg.split("\n");
|
|
};
|
|
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;
|
|
return resultString;
|
|
};
|
|
exports.deIndent = function (stringArg) {
|
|
var resultString;
|
|
var splitStringArray = splitString(stringArg);
|
|
splitStringArray = cleanStringArray(splitStringArray);
|
|
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;
|
|
};
|
|
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