refactor to const
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import * as plugins from './smartstring.plugins'
|
||||
|
||||
export let createRandomString = (
|
||||
export const createRandomString = (
|
||||
patternArg: string,
|
||||
lengthArg: number,
|
||||
optionsArg: any
|
||||
@ -8,6 +8,6 @@ export let createRandomString = (
|
||||
return plugins.randomatic(patternArg, lengthArg, optionsArg)
|
||||
}
|
||||
|
||||
export let createCryptoRandomString = (lengthArg): string => {
|
||||
export const createCryptoRandomString = (lengthArg): string => {
|
||||
return plugins.cryptoRandomString(lengthArg)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import * as plugins from './smartstring.plugins'
|
||||
* @param envArrayArg
|
||||
* @returns {}
|
||||
*/
|
||||
export let makeEnvObject = function (envArrayArg: string[]) {
|
||||
export const makeEnvObject = function (envArrayArg: string[]) {
|
||||
let returnObject = {}
|
||||
let regexString = /(.*)=(.*)/
|
||||
if (typeof envArrayArg !== 'undefined') {
|
||||
|
@ -24,13 +24,13 @@ export class GitRepo {
|
||||
/* ---------------------------------------------- *
|
||||
* ------------------ helpers ------------------- *
|
||||
* ---------------------------------------------- */
|
||||
let gitRegex = function (stringArg: string) {
|
||||
let regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-\.]*)(?:\/)([a-zA-Z0-9\-\.]*)(?:\.git)/
|
||||
const gitRegex = function (stringArg: string) {
|
||||
const regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-\.]*)(?:\/)([a-zA-Z0-9\-\.]*)(?:\.git)/
|
||||
let regexMatches = regexString.exec(stringArg)
|
||||
return regexMatches
|
||||
}
|
||||
|
||||
let gitLink = function (hostArg: string, userArg: string, repoArg: string, tokenArg: string = '', linkTypeArg): string {
|
||||
const gitLink = function (hostArg: string, userArg: string, repoArg: string, tokenArg: string = '', linkTypeArg): string {
|
||||
let returnString
|
||||
if (tokenArg !== '') {
|
||||
tokenArg = tokenArg + '@'
|
||||
|
@ -4,7 +4,7 @@ import * as plugins from './smartstring.plugins'
|
||||
* splits a string into an array
|
||||
* @param stringArg
|
||||
*/
|
||||
let splitStringAtLineBreak = (stringArg: string): string[] => {
|
||||
const splitStringAtLineBreak = (stringArg: string): string[] => {
|
||||
let resultArray = stringArg.split('\n')
|
||||
return cleanStringArray(resultArray)
|
||||
}
|
||||
@ -13,7 +13,7 @@ let splitStringAtLineBreak = (stringArg: string): string[] => {
|
||||
* joins a string together again
|
||||
* @param stringArrayArg
|
||||
*/
|
||||
let joinStringWithLineBreaks = (stringArrayArg: string[]): string => {
|
||||
const joinStringWithLineBreaks = (stringArrayArg: string[]): string => {
|
||||
let resultString: string = ''
|
||||
for (let line of stringArrayArg) {
|
||||
resultString = resultString + line + '\n' // add new line at end
|
||||
@ -25,7 +25,7 @@ let joinStringWithLineBreaks = (stringArrayArg: string[]): string => {
|
||||
* cleans first and last line in case they are empty
|
||||
* @param stringArrayArg
|
||||
*/
|
||||
let cleanStringArray = (stringArrayArg: string[]): string[] => {
|
||||
const cleanStringArray = (stringArrayArg: string[]): string[] => {
|
||||
let testRegex = /^[\s]*$/
|
||||
if (testRegex.test(stringArrayArg[ 0 ])) {
|
||||
stringArrayArg.shift()
|
||||
@ -41,7 +41,7 @@ let cleanStringArray = (stringArrayArg: string[]): string[] => {
|
||||
* @param stringArg
|
||||
* @param spaceAmount
|
||||
*/
|
||||
export let indent = (stringArg: string, spaceAmount: number): string => {
|
||||
export const indent = (stringArg: string, spaceAmount: number): string => {
|
||||
let localStringArray = splitStringAtLineBreak(stringArg)
|
||||
for (let stringArg of localStringArray) {
|
||||
stringArg = ' '.repeat(spaceAmount) + stringArg
|
||||
@ -55,7 +55,7 @@ export let indent = (stringArg: string, spaceAmount: number): string => {
|
||||
* @param stringArg
|
||||
* @param prefixArg
|
||||
*/
|
||||
export let indentWithPrefix = (stringArg: string, prefixArg: string): string => {
|
||||
export const indentWithPrefix = (stringArg: string, prefixArg: string): string => {
|
||||
let resultString: string
|
||||
let stringArray = splitStringAtLineBreak(stringArg)
|
||||
let resultArray: string[] = []
|
||||
@ -66,12 +66,14 @@ export let indentWithPrefix = (stringArg: string, prefixArg: string): string =>
|
||||
return resultString
|
||||
}
|
||||
|
||||
export let normalize = (stringArg: string): string => {
|
||||
export const normalize = (stringArg: string): string => {
|
||||
let resultString: string
|
||||
let splitStringArray: string[] = splitStringAtLineBreak(stringArg)
|
||||
let minCommonLeftOffset: number
|
||||
let deIndentRegex = /^(\s*)/
|
||||
let emptyLineRegex = /^(\s*)$/
|
||||
|
||||
const deIndentRegex = /^(\s*)/
|
||||
const emptyLineRegex = /^(\s*)$/
|
||||
|
||||
for (let stringItem of splitStringArray) {
|
||||
let offsetString = deIndentRegex.exec(stringItem)[ 1 ]
|
||||
if (
|
||||
|
@ -6,7 +6,7 @@ import * as plugins from './smartstring.plugins'
|
||||
* @param searchRegExp
|
||||
* @param replacementString
|
||||
*/
|
||||
export let replaceAll = (stringArg: string, searchRegExp: any, replacementString: string) => {
|
||||
export const replaceAll = (stringArg: string, searchRegExp: any, replacementString: string) => {
|
||||
return stringArg.replace(new RegExp(searchRegExp, 'g'), replacementString)
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ export let replaceAll = (stringArg: string, searchRegExp: any, replacementString
|
||||
* normalizes a string
|
||||
* @param stringArg
|
||||
*/
|
||||
export let standard = (stringArg: string): string => {
|
||||
export const 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
|
||||
|
@ -1,3 +1,3 @@
|
||||
import * as plugins from './smartstring.plugins'
|
||||
|
||||
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/
|
||||
export const regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/
|
||||
|
Reference in New Issue
Block a user