File size: 504 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
export function unionType(values: Iterable<any>, loosen = false) {
const baseType = Array.from(values)
.map((value) => JSON.stringify(value))
.join(" | ")
if (loosen) {
return `${baseType} | (string & {})`
}
return baseType
}
export function capitalize(value: string) {
return value.charAt(0).toUpperCase() + value.slice(1)
}
export const isBooleanValue = (value: string) =>
value === "true" || value === "false"
export const uniq = <T>(arr: T[]) => Array.from(new Set(arr))
|