This repository has been archived on 2026-04-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
AsaJS/scripts/custom.ts
2026-01-18 03:24:03 +07:00

17 lines
455 B
TypeScript

export {}
declare global {
interface String {
toCamelCase(upcaseTop?: boolean): string
toSnakeCase(): string
}
}
String.prototype.toCamelCase = function (this: string, upcaseTop: boolean): string {
const a = this.replace(/_([a-z])/g, g => g[1].toUpperCase())
return upcaseTop ? a.charAt(0).toUpperCase() + a.slice(1) : a
}
String.prototype.toSnakeCase = function (this: string): string {
return this.replace(/([A-Z])/g, "_$1").toLowerCase()
}