2016-07-06 08:04:25 +00:00
|
|
|
import * as plugins from "./smartstring.plugins";
|
|
|
|
|
|
|
|
let splitString = (stringArg:string):string[] => {
|
2016-07-07 17:53:14 +00:00
|
|
|
return stringArg.split("\n");
|
2016-07-06 08:04:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
let joinString = (stringArrayArg:string[]):string => {
|
2016-07-07 17:53:14 +00:00
|
|
|
let resultString:string = "";
|
2016-07-06 08:04:25 +00:00
|
|
|
for(let line of stringArrayArg){
|
2016-07-07 17:53:14 +00:00
|
|
|
resultString = resultString + line + "\n";
|
2016-07-06 08:04:25 +00:00
|
|
|
};
|
2016-07-07 17:53:14 +00:00
|
|
|
return resultString;
|
2016-07-06 08:04:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export let indent = (stringArg:string,spaceAmount:number):string => {
|
2016-07-07 17:53:14 +00:00
|
|
|
let resultString:string;
|
|
|
|
return resultString;
|
2016-07-06 08:04:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export let indentWithPrefix = (stringArg:string,prefixArg:string):string => {
|
2016-07-07 17:53:14 +00:00
|
|
|
let resultString:string;
|
|
|
|
return resultString;
|
2016-07-06 08:04:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export let deIndent = (stringArg:string):string => {
|
2016-07-07 17:53:14 +00:00
|
|
|
let resultString:string;
|
|
|
|
let splitStringArray:string[] = splitString(stringArg);
|
|
|
|
let minCommonLeftOffset:number;
|
|
|
|
let deIndentRegex = /^(\s*)/;
|
|
|
|
for(let stringItem of splitStringArray){
|
|
|
|
let offsetString = deIndentRegex.exec(stringItem)[1];
|
|
|
|
if (typeof minCommonLeftOffset == "undefined" || offsetString.length < minCommonLeftOffset){
|
|
|
|
minCommonLeftOffset = offsetString.length;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let resultSplitStringArray = [];
|
|
|
|
for(let stringItem of splitStringArray){
|
|
|
|
resultSplitStringArray.push(stringItem.substr(minCommonLeftOffset));
|
|
|
|
};
|
|
|
|
resultString = joinString(resultSplitStringArray);
|
|
|
|
return resultString;
|
2016-07-06 08:04:25 +00:00
|
|
|
}
|