Skip to content

Commit

Permalink
Const enums are bad in libraries, rewrite Order
Browse files Browse the repository at this point in the history
  • Loading branch information
gigobyte committed Jul 7, 2024
1 parent bce198e commit 649d492
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ export const always =
() =>
x

export const enum Order {
LT = 'LT',
EQ = 'EQ',
GT = 'GT'
}
export const Order = {
LT: 'LT',
EQ: 'EQ',
GT: 'GT'
} as const

export type Order = 'LT' | 'EQ' | 'GT'

/** Compares two values using the default "<" and ">" operators */
export const compare = <T>(x: T, y: T): Order => {
Expand Down Expand Up @@ -47,8 +49,8 @@ export type CurriedFn<TAllArgs extends any[], TReturn> = <
) => TProvidedArgs extends TAllArgs
? TReturn
: TAllArgs extends [...TupleOfLength<TProvidedArgs>, ...infer TRestOfArgs]
? CurriedFn<TRestOfArgs, TReturn>
: never
? CurriedFn<TRestOfArgs, TReturn>
: never

/** Takes a function that receives multiple arguments and returns a "curried" version of that function that can take any number of those arguments and if they are less than needed a new function that takes the rest of them will be returned */
export const curry = <TArgs extends any[], TReturn>(
Expand Down

0 comments on commit 649d492

Please sign in to comment.