mtcute/packages/tl-utils/src/codegen/utils.ts
teidesu 9493759572 build: updated to layer 139
didn't add any new layers' features, only bumped layer
2022-04-01 22:17:10 +03:00

24 lines
633 B
TypeScript

export const snakeToCamel = (s: string): string => {
return s.replace(/(?<!^|_)(_[a-z0-9])/gi, ($1) => {
return $1.substr(1).toUpperCase()
})
}
export const camelToPascal = (s: string): string =>
s[0].toUpperCase() + s.substr(1)
export function jsComment(s: string): string {
return (
'/**' +
s
.replace(/(?![^\n]{1,60}$)([^\n]{1,60})\s/g, '$1\n')
.replace(/\n|^/g, '\n * ') +
'\n */'
)
}
export function indent(size: number, s: string): string {
let prefix = ''
while (size--) prefix += ' '
return prefix + s.replace(/\n/g, '\n' + prefix)
}