draft-redmine_users_from_csv/utils.ts

16 lines
515 B
TypeScript
Raw Normal View History

export function sanitize(str: string): string {
return str.replaceAll(' ', '_')
}
export function capitalize(str: string): string {
return str
.split(' ')
.map(word => word.split(''))
.map(([firstLetter, ...tail]) => `${firstLetter.toLocaleUpperCase()}${tail.join().toLocaleLowerCase()}`)
.join(' ')
}
export function toLogin(firstname: string, lastname: string): string {
return `${sanitize(firstname.toLocaleLowerCase())}.${sanitize(lastname.toLocaleLowerCase())}`
}