export function capitalize(string) {
console.assert(typeof string === "string", string);
return string.substring(0, 1).toUpperCase() + string.substring(1);
}
export function compareNatural(a, b) {
console.assert(typeof a === "string", a);
console.assert(typeof b === "string", b);
const locales = undefined;
return String(a).localeCompare(String(b), locales, {numeric: true});
}
export function substitute(template, substitutions, combine) {
console.assert(typeof template === "string", template);
console.assert(typeof substitutions === "object", substitutions);
console.assert(typeof combine === "function", combine);
let substitute = false;
for (let part of template.split(/(%)(.+?)(%)/)) {
if (part === "%")
substitute = !substitute;
else if (substitute)
combine(substitutions[part]);
else
combine(part);
}
}