airship-server
Version:
Airship is a framework for Node.JS & TypeScript that helps you to write big, scalable and maintainable API servers.
18 lines (11 loc) • 478 B
text/typescript
export type Wrapper<T> = { [P in keyof T]: T[P] }
export function toCamelCase(str: string, capitalize: boolean = false, separator = '_') {
const parts = str.split(separator)
if (!parts.length) return str
const capitalized = parts.slice(1).map(part => part[0].toUpperCase() + part.substr(1))
capitalized.unshift(parts[0])
let result = capitalized.join('')
if (capitalize)
return result[0].toUpperCase() + result.slice(1)
return result
}