UNPKG

1.47 kBTypeScriptView Raw
1import { If, Not, And, Or } from 'typescript-logic';
2export declare type Extends<A, B> = Or<Any<B>, If<Any<A>, Any<B>, prv.Extends<A, B>>>;
3export declare type Compare<A, B, Options extends Compare.Options = Compare.Options.Default> = If<Extends<A, B>, If<Extends<B, A>, Options['equal' | 'broaderRight' | 'broaderLeft'], Options['broaderRight']>, If<Extends<B, A>, Options['broaderLeft'], Options['mismatch']>>;
4export declare namespace Compare {
5 type Strict<A, B, Options extends Compare.Options = Compare.Options.Default> = If<Extends<A, B>, If<Extends<B, A>, Options['equal'], Options['broaderRight']>, If<Extends<B, A>, Options['broaderLeft'], Options['mismatch']>>;
6 interface Options {
7 broaderLeft: any;
8 broaderRight: any;
9 equal: any;
10 mismatch: any;
11 }
12 namespace Options {
13 interface Default extends Compare.Options {
14 broaderLeft: 'broaderLeft';
15 broaderRight: 'broaderRight';
16 equal: 'equal';
17 mismatch: 'mismatch';
18 }
19 }
20}
21export declare type Equal<A, B> = Or<And<Any<A>, Any<B>>, And<And<NotAny<A>, NotAny<B>>, And<Extends<A, B>, Extends<B, A>>>>;
22export declare type NotEqual<A, B> = Not<Equal<A, B>>;
23export declare type Any<Type> = And<prv.Extends<Type, 0>, prv.Extends<Type, 1>>;
24export declare type NotAny<Type, True = true, False = true> = Not<Any<Type>>;
25declare namespace prv {
26 type Extends<A, B> = [A] extends [B] ? true : false;
27}
28export {};