MCPcopy Create free account
hub / github.com/FlashpointProject/launcher / parseVariableString

Function parseVariableString

src/shared/utils/VariableString.ts:19–28  ·  view source on GitHub ↗
(str: string, getValue: GetVariableStringValue, options: VariableStringOptions = defaultOptions)

Source from the content-addressed store, hash-verified

17 * @param options Options used when splitting variable strings E.G open and close markers
18 */
19export function parseVariableString(str: string, getValue: GetVariableStringValue, options: VariableStringOptions = defaultOptions): string {
20 const arr = splitVariableString(str, options);
21 return (arr.length > 0)
22 ? arr.reduce((acc, val, index) => acc + (
23 (index % 2 === 1)
24 ? getValue(val)
25 : val
26 ))
27 : '';
28}
29
30/**
31 * Split a "variable string" into an array.

Callers 2

parseVarStrFunction · 0.90
parseAppVarFunction · 0.90

Calls 1

splitVariableStringFunction · 0.85

Tested by

no test coverage detected