Skip to content

Commit

Permalink
style: format source code
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jan 29, 2024
1 parent 6e412b2 commit 9dd9d85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
33 changes: 17 additions & 16 deletions src/schema/camelcase_types.ts
Expand Up @@ -32,11 +32,12 @@ type Separator = '_' | '-'

type IncludesSeparator<Type> = Type extends `${string}${Separator}${string}` ? true : false

type IsOneWord<Type> = Type extends Lowercase<Type & string>
? true
: Type extends Uppercase<Type & string>
type IsOneWord<Type> =
Type extends Lowercase<Type & string>
? true
: false
: Type extends Uppercase<Type & string>
? true
: false

type IsCamelCase<Type> = Type extends Uncapitalize<Type & string> ? true : false

Expand Down Expand Up @@ -68,15 +69,16 @@ type PascalCaseParser<Type, Tuple extends readonly any[] = []> = Type extends ''
: never
: never

type SplitAnyCase<Type> = IncludesSeparator<Type> extends true
? SeparatorCaseParser<Type>
: IsOneWord<Type> extends true
? [Lowercase<Type & string>]
: IsCamelCase<Type> extends true
? CamelCaseParser<Type>
: IsPascalCase<Type> extends true
? PascalCaseParser<Type>
: []
type SplitAnyCase<Type> =
IncludesSeparator<Type> extends true
? SeparatorCaseParser<Type>
: IsOneWord<Type> extends true
? [Lowercase<Type & string>]
: IsCamelCase<Type> extends true
? CamelCaseParser<Type>
: IsPascalCase<Type> extends true
? PascalCaseParser<Type>
: []

type PascalCapitalizer<Type, Tuple extends readonly any[] = []> = Type extends [
infer Head,
Expand All @@ -97,6 +99,5 @@ type Join<Type, JoinedString extends string = ''> = Type extends [infer Head, ..
: Join<Tail>
: JoinedString

export type CamelCase<Type> = IsStringLiteral<Type> extends true
? Join<CamelCapitalizer<SplitAnyCase<Type>>>
: Type
export type CamelCase<Type> =
IsStringLiteral<Type> extends true ? Join<CamelCapitalizer<SplitAnyCase<Type>>> : Type
4 changes: 2 additions & 2 deletions tsconfig.json
Expand Up @@ -2,6 +2,6 @@
"extends": "@adonisjs/tsconfig/tsconfig.package.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "./build"
}
"outDir": "./build",
},
}

0 comments on commit 9dd9d85

Please sign in to comment.