@stackoverfloweth/prefect-design
Version:
A collection of low-level Vue components.
35 lines (30 loc) • 811 B
text/typescript
export function toPluralString(word: string, count: number): string {
if (count == 1) {
return word
}
const ending = ['s', 'sh', 'ch', 'x', 'z'].some((chars) => word.endsWith(chars),
)
? 'es'
: 's'
return `${word}${ending}`
}
export function kebabCase(string: string): string {
return string
.replace(/([a-z])([A-Z])/g, '$1-$2')
.replace(/[\s_]+/g, '-')
.toLowerCase()
}
export function unescapeHtml(str: string): string {
return str.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, "'")
.replace(/&/g, '&')
}
export function escapeHtml(str: string): string {
return str.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''')
}