Mild refactor of stringSplit to make it easier to understand.
This commit is contained in:
parent
b5672d676f
commit
2bfa4c6f91
|
@ -128,18 +128,20 @@ export function substituteLoopStep(hbsString: string, substitute: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stringSplit(value: string | string[]) {
|
export function stringSplit(value: string | string[]) {
|
||||||
if (value == null || Array.isArray(value)) {
|
if (value == null) {
|
||||||
return value || []
|
return []
|
||||||
|
}
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return value
|
||||||
}
|
}
|
||||||
if (typeof value !== "string") {
|
if (typeof value !== "string") {
|
||||||
throw new Error(`Unable to split value of type ${typeof value}: ${value}`)
|
throw new Error(`Unable to split value of type ${typeof value}: ${value}`)
|
||||||
}
|
}
|
||||||
if (value.split("\n").length > 1) {
|
const splitOnNewLine = value.split("\n")
|
||||||
value = value.split("\n")
|
if (splitOnNewLine.length > 1) {
|
||||||
} else {
|
return splitOnNewLine
|
||||||
value = value.split(",")
|
|
||||||
}
|
}
|
||||||
return value
|
return value.split(",")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function typecastForLooping(loopStep: LoopStep, input: LoopInput) {
|
export function typecastForLooping(loopStep: LoopStep, input: LoopInput) {
|
||||||
|
|
Loading…
Reference in New Issue