2024-01-15 21:29:47 +01:00
|
|
|
export function sanitize(str: string): string {
|
2024-01-15 21:59:22 +01:00
|
|
|
return str.replaceAll(' ', '_')
|
2024-01-15 21:29:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export function capitalize(str: string): string {
|
2024-01-15 21:59:22 +01:00
|
|
|
return str
|
|
|
|
.split(' ')
|
|
|
|
.map((word) => word.split(''))
|
|
|
|
.map(([firstLetter, ...tail]) =>
|
|
|
|
`${firstLetter.toLocaleUpperCase()}${tail.join().toLocaleLowerCase()}`
|
|
|
|
)
|
|
|
|
.join(' ')
|
2024-01-15 21:29:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export function toLogin(firstname: string, lastname: string): string {
|
2024-01-15 21:59:22 +01:00
|
|
|
return `${sanitize(firstname.toLocaleLowerCase())}.${
|
|
|
|
sanitize(lastname.toLocaleLowerCase())
|
|
|
|
}`
|
|
|
|
}
|
|
|
|
|
|
|
|
export const log = {
|
|
|
|
info(message: string) {
|
|
|
|
console.log(
|
|
|
|
`%c[info]%c ${message}`,
|
|
|
|
'color: cyan; font-weight: bold',
|
|
|
|
'color: white',
|
|
|
|
)
|
|
|
|
},
|
|
|
|
error(message: string) {
|
|
|
|
console.error(
|
|
|
|
`%c[error]%c ${message}`,
|
|
|
|
'color: red; font-weight: bold',
|
|
|
|
'color: white',
|
|
|
|
)
|
|
|
|
},
|
2024-01-15 21:29:47 +01:00
|
|
|
}
|