2022-03-18 21:50:24 +00:00
|
|
|
import * as plugins from './smartstring.plugins.js';
|
2017-10-05 13:55:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* replaces all occurences of something in a string
|
|
|
|
* @param stringArg
|
2019-01-12 19:19:16 +00:00
|
|
|
* @param searchPattern
|
2018-07-21 12:37:39 +00:00
|
|
|
* @param replacementString
|
2017-10-05 13:55:59 +00:00
|
|
|
*/
|
2019-01-12 19:19:16 +00:00
|
|
|
export const replaceAll = (stringArg: string, searchPattern: string, replacementString: string) => {
|
|
|
|
return stringArg.replace(new RegExp(searchPattern, 'g'), replacementString);
|
2018-07-21 12:37:39 +00:00
|
|
|
};
|
2017-10-05 13:55:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* normalizes a string
|
|
|
|
* @param stringArg
|
|
|
|
*/
|
2017-10-26 13:24:10 +00:00
|
|
|
export const standard = (stringArg: string): string => {
|
2018-07-21 12:37:39 +00:00
|
|
|
let fix1 = plugins.stripIndent(stringArg); // fix indention
|
|
|
|
let fix2 = plugins.normalizeNewline(fix1); // fix newlines
|
2019-01-12 19:19:16 +00:00
|
|
|
let fix3 = replaceAll(fix2, '\t/', ' '); // fix tabs
|
2018-07-21 12:37:39 +00:00
|
|
|
return fix3;
|
|
|
|
};
|