(a: T, b: T)
| 53 | |
| 54 | // For Array.prototype.sort |
| 55 | export function basic_comparator<T>(a: T, b: T) { |
| 56 | if (a < b) { |
| 57 | return -1; |
| 58 | } |
| 59 | if (a > b) { |
| 60 | return 1; |
| 61 | } |
| 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | // https://stackoverflow.com/questions/41253310/typescript-retrieve-element-type-information-from-array-type |
| 66 | export type ElementType<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer T)[] ? T : never; |