update normalize of smartstring
This commit is contained in:
22
ts/smartstring.normalize.ts
Normal file
22
ts/smartstring.normalize.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as plugins from './smartstring.plugins'
|
||||
|
||||
/**
|
||||
* replaces all occurences of something in a string
|
||||
* @param stringArg
|
||||
* @param searchRegExp
|
||||
* @param replacementString
|
||||
*/
|
||||
export let replaceAll = (stringArg: string, searchRegExp: any, replacementString: string) => {
|
||||
return stringArg.replace(new RegExp(searchRegExp, 'g'), replacementString)
|
||||
}
|
||||
|
||||
/**
|
||||
* normalizes a string
|
||||
* @param stringArg
|
||||
*/
|
||||
export let standard = (stringArg: string): string => {
|
||||
let fix1 = plugins.stripIndent(stringArg) // fix indention
|
||||
let fix2 = plugins.normalizeNewline(fix1) // fix newlines
|
||||
let fix3 = replaceAll(fix2, /\t/, ' ') // fix tabs
|
||||
return fix3
|
||||
}
|
Reference in New Issue
Block a user