Sha256: 1c0c6bd0d9b697040f43723d5b1dd6bb9feb743459ff9f95fda9adb6c97c9b37

Contents?: true

Size: 1.43 KB

Versions: 28

Compression:

Stored size: 1.43 KB

Contents

import type {NumberAbsolute, PositiveNumericStringGt} from './internal';
import type {IsEqual} from './is-equal';
import type {PositiveInfinity, NegativeInfinity, IsNegative} from './numeric';
import type {And} from './and';
import type {Or} from './or';

/**
Returns a boolean for whether a given number is greater than another number.

@example
```
import type {GreaterThan} from 'type-fest';

GreaterThan<1, -5>;
//=> true

GreaterThan<1, 1>;
//=> false

GreaterThan<1, 5>;
//=> false
```
*/
export type GreaterThan<A extends number, B extends number> = number extends A | B
	? never
	: [
		IsEqual<A, PositiveInfinity>, IsEqual<A, NegativeInfinity>,
		IsEqual<B, PositiveInfinity>, IsEqual<B, NegativeInfinity>,
	] extends infer R extends [boolean, boolean, boolean, boolean]
		? Or<
		And<IsEqual<R[0], true>, IsEqual<R[2], false>>,
		And<IsEqual<R[3], true>, IsEqual<R[1], false>>
		> extends true
			? true
			: Or<
			And<IsEqual<R[1], true>, IsEqual<R[3], false>>,
			And<IsEqual<R[2], true>, IsEqual<R[0], false>>
			> extends true
				? false
				: true extends R[number]
					? false
					: [IsNegative<A>, IsNegative<B>] extends infer R extends [boolean, boolean]
						? [true, false] extends R
							? false
							: [false, true] extends R
								? true
								: [false, false] extends R
									? PositiveNumericStringGt<`${A}`, `${B}`>
									: PositiveNumericStringGt<`${NumberAbsolute<B>}`, `${NumberAbsolute<A>}`>
						: never
		: never;

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.25 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.24 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.23 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.22 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.21 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.20 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.19 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.18 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.17 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.16 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.15 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.14 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.13 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.12 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.11 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.10 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.9 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.8 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts
clapton-0.0.7 lib/clapton/javascripts/node_modules/type-fest/source/greater-than.d.ts