ignore empty lines for indent.normalize()
This commit is contained in:
parent
9c60105685
commit
543dc98961
2
dist/smartstring.indent.d.ts
vendored
2
dist/smartstring.indent.d.ts
vendored
@ -1,3 +1,3 @@
|
||||
export declare let indent: (stringArg: string, spaceAmount: number) => string;
|
||||
export declare let indentWithPrefix: (stringArg: string, prefixArg: string) => string;
|
||||
export declare let normalizeIndent: (stringArg: string) => string;
|
||||
export declare let normalize: (stringArg: string) => string;
|
||||
|
8
dist/smartstring.indent.js
vendored
8
dist/smartstring.indent.js
vendored
@ -39,15 +39,17 @@ exports.indentWithPrefix = function (stringArg, prefixArg) {
|
||||
resultString = joinString(resultArray);
|
||||
return resultString;
|
||||
};
|
||||
exports.normalizeIndent = function (stringArg) {
|
||||
exports.normalize = function (stringArg) {
|
||||
var resultString;
|
||||
var splitStringArray = splitString(stringArg);
|
||||
var minCommonLeftOffset;
|
||||
var deIndentRegex = /^(\s*)/;
|
||||
var emptyLineRegex = /^(\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) {
|
||||
if ((typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset)
|
||||
&& !emptyLineRegex.test(stringItem)) {
|
||||
minCommonLeftOffset = offsetString.length;
|
||||
}
|
||||
;
|
||||
@ -62,4 +64,4 @@ exports.normalizeIndent = function (stringArg) {
|
||||
resultString = joinString(resultSplitStringArray);
|
||||
return resultString;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuaW5kZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuaW5kZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3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UJBQW1CLEdBQUcsWUFBWSxDQUFDLE1BQU0sQ0FBQztRQUM5QyxDQUFDO1FBQUEsQ0FBQztLQUNMO0lBQUEsQ0FBQztJQUNGLElBQUksc0JBQXNCLEdBQUcsRUFBRSxDQUFDO0lBQ2hDLEdBQUcsQ0FBQSxDQUFtQixVQUFnQixFQUFoQixxQ0FBZ0IsRUFBaEIsOEJBQWdCLEVBQWhCLElBQWdCLENBQUM7UUFBbkMsSUFBSSxVQUFVLHlCQUFBO1FBQ2Qsc0JBQXNCLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsbUJBQW1CLENBQUMsQ0FBQyxDQUFDO0tBQ3ZFO0lBQUEsQ0FBQztJQUNGLFlBQVksR0FBRyxVQUFVLENBQUMsc0JBQXNCLENBQUMsQ0FBQztJQUNsRCxNQUFNLENBQUMsWUFBWSxDQUFDO0FBQ3hCLENBQUMsQ0FBQSJ9
|
12
test/test.js
12
test/test.js
@ -69,11 +69,13 @@ describe("smartstring", function () {
|
||||
});
|
||||
});
|
||||
describe(".indent", function () {
|
||||
var testString = "\n base\n should be indented\n some more\n base\n indented\n ";
|
||||
describe(".normalizeIndent()", function () {
|
||||
it("should normalizeIndent a string", function () {
|
||||
testString = smartstring.indent.normalizeIndent(testString);
|
||||
var testString = "\n base\n should be indented\n some more\n\n base\n indented\n ";
|
||||
describe(".normalize()", function () {
|
||||
it("should normalize a string", function () {
|
||||
testString = smartstring.indent.normalize(testString);
|
||||
console.log(testString);
|
||||
var zoneNameArg = "test1";
|
||||
var destinationIpArg = "111";
|
||||
});
|
||||
});
|
||||
describe(".indentWithPrefix", function () {
|
||||
@ -96,4 +98,4 @@ describe("smartstring", function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltd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QUFVLENBQUMsQ0FBQztZQUM1QixDQUFDLENBQUMsQ0FBQTtRQUNOLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUM7SUFDSCxRQUFRLENBQUMsYUFBYSxFQUFDO1FBQ25CLFFBQVEsQ0FBQyxpQkFBaUIsRUFBQztZQUN2QixFQUFFLENBQUMsOEJBQThCLEVBQUM7Z0JBQzlCLFdBQVcsQ0FBQyxVQUFVLENBQUMsa0JBQWtCLENBQUMsSUFBSSxDQUFDLDZCQUE2QixDQUFDO3FCQUN4RSxNQUFNLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxDQUFDO2dCQUN0QixXQUFXLENBQUMsVUFBVSxDQUFDLGtCQUFrQixDQUFDLElBQUksQ0FBQywyQkFBMkIsQ0FBQztxQkFDdEUsTUFBTSxDQUFDLEVBQUUsQ0FBQyxJQUFJLEVBQUUsQ0FBQztnQkFDdEIsV0FBVyxDQUFDLFVBQVUsQ0FBQyxrQkFBa0IsQ0FBQyxJQUFJLENBQUMsNEJBQTRCLENBQUM7cUJBQ3ZFLE1BQU0sQ0FBQyxFQUFFLENBQUMsS0FBSyxFQUFFLENBQUM7WUFDM0IsQ0FBQyxDQUFDLENBQUE7UUFDTixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUMifQ==
|
@ -73,13 +73,16 @@ describe("smartstring",function(){
|
||||
base
|
||||
should be indented
|
||||
some more
|
||||
|
||||
base
|
||||
indented
|
||||
`;
|
||||
describe(".normalizeIndent()",function(){
|
||||
it("should normalizeIndent a string",function(){
|
||||
testString = smartstring.indent.normalizeIndent(testString);
|
||||
describe(".normalize()",function(){
|
||||
it("should normalize a string",function(){
|
||||
testString = smartstring.indent.normalize(testString);
|
||||
console.log(testString);
|
||||
let zoneNameArg = "test1";
|
||||
let destinationIpArg = "111";
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -40,14 +40,18 @@ export let indentWithPrefix = (stringArg:string,prefixArg:string):string => {
|
||||
return resultString;
|
||||
};
|
||||
|
||||
export let normalizeIndent = (stringArg:string):string => {
|
||||
export let normalize = (stringArg:string):string => {
|
||||
let resultString:string;
|
||||
let splitStringArray:string[] = splitString(stringArg);
|
||||
let minCommonLeftOffset:number;
|
||||
let deIndentRegex = /^(\s*)/;
|
||||
let emptyLineRegex = /^(\s*)$/
|
||||
for(let stringItem of splitStringArray){
|
||||
let offsetString = deIndentRegex.exec(stringItem)[1];
|
||||
if (typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset){
|
||||
if (
|
||||
(typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset)
|
||||
&& !emptyLineRegex.test(stringItem)
|
||||
){
|
||||
minCommonLeftOffset = offsetString.length;
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user