36 lines
958 B
TypeScript
36 lines
958 B
TypeScript
export class StringUtils
|
|
{
|
|
static format(template: string, ...varContext: string[]): string
|
|
{
|
|
const context = Array.from(varContext);
|
|
let contextIndex = 0;
|
|
while (template.includes("%s"))
|
|
{
|
|
const currentContext = context.at(contextIndex);
|
|
if (currentContext != null)
|
|
{
|
|
template = template.replace("%s", currentContext);
|
|
contextIndex++;
|
|
}
|
|
else
|
|
{
|
|
return template;
|
|
}
|
|
}
|
|
return template;
|
|
}
|
|
|
|
static equals(first: string | null | undefined, second: string | null | undefined): boolean
|
|
{
|
|
return first === second;
|
|
}
|
|
|
|
static startsWith(input: string | null | undefined, start: string | null | undefined)
|
|
{
|
|
if (input != null && start != null)
|
|
{
|
|
return input.startsWith(start);
|
|
}
|
|
return undefined;
|
|
}
|
|
} |