-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
308 additions
and
198 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,71 @@ | ||
import type { BigintType } from './bigint_type.js' | ||
import type { SelectWithDistribute } from '../type_plus/branch/select_with_distribute.js' | ||
|
||
/** | ||
* Is the type `T` exactly `bigint`. | ||
* 🎭 *predicate* | ||
* | ||
* Validate if `T` is `bigint` or `bigint` literals. | ||
* | ||
* @example | ||
* ```ts | ||
* type R = IsBigint<bigint> // true | ||
* type R = isBigint<bigint> // true | ||
* type R = isBigint<1n> // true | ||
* | ||
* type R = isBigint<never> // false | ||
* type R = isBigint<unknown> // false | ||
* type R = isBigint<string | boolean> // false | ||
* | ||
* type R = IsBigint<1n> // false | ||
* type R = IsBigint<number> // false | ||
* type R = IsBigint<bigint | boolean> // false | ||
* type R = IsBigint<unknown> // false | ||
* type R = isBigint<string | bigint> // boolean | ||
* ``` | ||
* | ||
* 🔢 *customize* | ||
* | ||
* Filter to ensure `T` is `bigint` or `bigint` literals, otherwise returns `never`. | ||
* | ||
* @example | ||
* ```ts | ||
* type R = isBigint<bigint, { selection: 'filter' }> // bigint | ||
* type R = isBigint<1n, { selection: 'filter' }> // bigint | ||
* | ||
* type R = isBigint<never, { selection: 'filter' }> // never | ||
* type R = isBigint<unknown, { selection: 'filter' }> // never | ||
* type R = isBigint<string | boolean, { selection: 'filter' }> // never | ||
* | ||
* type R = isBigint<string | bigint> // bigint | ||
* ``` | ||
* | ||
* 🔢 *customize* | ||
* | ||
* Filter to ensure `T` is `bigint` or `bigint` literals, otherwise returns `unknown`. | ||
* | ||
* @example | ||
* ```ts | ||
* type R = isBigint<string | boolean, { selection: 'filter-unknown' }> // unknown | ||
* type R = isBigint<string | bigint, { selection: 'filter-unknown' }> // unknown | ||
* ``` | ||
* | ||
* 🔢 *customize*: | ||
* | ||
* Disable distribution of union types. | ||
* | ||
* ```ts | ||
* type R = isBigint<bigint | 1> // boolean | ||
* type R = isBigint<bigint | 1, { distributive: false }> // false | ||
* ``` | ||
* | ||
* 🔢 *customize* | ||
* | ||
* Use unique branch identifiers to allow precise processing of the result. | ||
* | ||
* @example | ||
* ```ts | ||
* type R = isBigint<bigint, $SelectionBranch> // $Then | ||
* type R = isBigint<string, $SelectionBranch> // $Else | ||
* ``` | ||
*/ | ||
export type IsBigint<T, Then = true, Else = false> = BigintType<T, Then, Else> | ||
export type IsBigint<T, $O extends IsBigint.$Options = {}> = SelectWithDistribute<T, bigint, $O> | ||
|
||
export namespace IsBigint { | ||
export type $Options = SelectWithDistribute.$Options | ||
export type $Default = SelectWithDistribute.$Default | ||
export type $Branch = SelectWithDistribute.$Branch | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,71 @@ | ||
import type { BigintType } from './bigint_type.js' | ||
import type { SelectInvertWithDistribute } from '../type_plus/branch/select_invert_with_distribute.js' | ||
|
||
/** | ||
* Is the type `T` not exactly `null`. | ||
* 🎭 *predicate* | ||
* | ||
* Validate if `T` is not `bigint` nor `bigint` literals. | ||
* | ||
* @example | ||
* ```ts | ||
* type R = IsNotBigint<bigint> // false | ||
* type R = IsNotBigint<1n> // false | ||
* | ||
* type R = IsNotBigint<1n> // true | ||
* type R = IsNotBigint<number> // true | ||
* type R = IsNotBigint<bigint | boolean> // true | ||
* type R = IsNotBigint<never> // true | ||
* type R = IsNotBigint<unknown> // true | ||
* type R = IsNotBigint<string | boolean> // true | ||
* ``` | ||
* | ||
* 🔢 *customize* | ||
* | ||
* Filter to ensure `T` is not `bigint` nor `bigint` literals, otherwise returns `never`. | ||
* | ||
* @example | ||
* ```ts | ||
* type R = IsNotBigint<bigint, { selection: 'filter' }> // never | ||
* type R = IsNotBigint<1n, { selection: 'filter' }> // never | ||
* | ||
* type R = IsNotBigint<never, { selection: 'filter' }> // never | ||
* type R = IsNotBigint<unknown, { selection: 'filter' }> // unknown | ||
* type R = IsNotBigint<string | boolean, { selection: 'filter' }> // string | boolean | ||
* ``` | ||
* | ||
* 🔢 *customize* | ||
* | ||
* Filter to ensure `T` is not `bigint` nor `bigint` literals, otherwise returns `unknown`. | ||
* | ||
* @example | ||
* ```ts | ||
* type R = IsNotBigint<bigint, { selection: 'filter-unknown' }> // unknown | ||
* type R = IsNotBigint<1n, { selection: 'filter-unknown' }> // unknown | ||
* | ||
* type R = IsNotBigint<string | boolean, { selection: 'filter-unknown' }> // string | boolean | ||
* type R = IsNotBigint<string | bigint, { selection: 'filter-unknown' }> // unknown | ||
* ``` | ||
* | ||
* 🔢 *customize* | ||
* | ||
* Disable distribution of union types. | ||
* | ||
* @example | ||
* ```ts | ||
* type R = IsNotBigint<bigint | 1> // boolean | ||
* type R = IsNotBigint<bigint | 1, { distributive: false }> // true | ||
* ``` | ||
* | ||
* 🔢 *customize* | ||
* | ||
* Use unique branch identifiers to allow precise processing of the result. | ||
* | ||
* @example | ||
* ```ts | ||
* type R = IsNotBigint<string, $SelectionBranch> // $Then | ||
* type R = IsNotBigint<bigint, $SelectionBranch> // $Else | ||
* ``` | ||
*/ | ||
export type IsNotBigint<T, Then = true, Else = false> = BigintType<T, Else, Then> | ||
export type IsNotBigint<T, $O extends IsNotBigint.$Options = {}> = SelectInvertWithDistribute<T, bigint, $O> | ||
|
||
export namespace IsNotBigint { | ||
export type $Options = SelectInvertWithDistribute.$Options | ||
export type $Default = SelectInvertWithDistribute.$Default | ||
export type $Branch = SelectInvertWithDistribute.$Branch | ||
} |
Oops, something went wrong.