refactor to const

This commit is contained in:
2017-10-26 15:24:10 +02:00
parent 4a94ce3038
commit 235f380139
19 changed files with 48 additions and 41 deletions

View File

@ -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)
}

View File

@ -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') {

View File

@ -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 + '@'

View File

@ -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 (

View File

@ -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

View File

@ -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]?/