UNPKG

cds-plugin-handlers

Version:
13 lines (10 loc) 498 B
import { resolve } from 'path'; import { promises } from 'fs'; export function camelize(str: string): string { return str.toLowerCase().replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) { return index == 0 ? word.toLowerCase() : word.toUpperCase(); }).replace(/\s+/g, ''); } export function titleize (str: string): string { return str.toLowerCase().split(' ').map(word => word.length === 2 ? word.toUpperCase() : word.charAt(0).toUpperCase() + word.slice(1)).join(' '); }