Sometimes a function should accept either a single item or an array of items. Use Array.isArray to decide which one you have and normalize to one consistent shape.
function ensureArray(s: string | string[]) {
return Array.isArray(s) ? s : [s];
}
Return a new array every time so callers can safely reuse the result.
Normalize input into an array of strings.