lay-sing 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/main/expect/index.d.ts +1 -2
- package/esm/main/expect/index.d.ts.map +1 -1
- package/esm/main/expect/index.js.map +1 -1
- package/esm/main/expect/to/be.d.ts +12 -12
- package/esm/main/expect/to/be.d.ts.map +1 -1
- package/esm/main/expect/to/be.js.map +1 -1
- package/esm/main/expect/to/equal.d.ts +4 -4
- package/esm/main/expect/to/equal.d.ts.map +1 -1
- package/esm/main/expect/to/equal.js.map +1 -1
- package/esm/main/expect/to/extend.d.ts +9 -9
- package/esm/main/expect/to/extend.d.ts.map +1 -1
- package/esm/main/expect/to/extend.js.map +1 -1
- package/esm/main/expect/to/have-key.d.ts +6 -6
- package/esm/main/expect/to/have-key.d.ts.map +1 -1
- package/esm/main/expect/to/have-key.js.map +1 -1
- package/esm/main/expect/to/index.d.ts +8 -6
- package/esm/main/expect/to/index.d.ts.map +1 -1
- package/esm/main/expect/to/index.js.map +1 -1
- package/esm/main/expect/to/proper-extends.d.ts +4 -4
- package/esm/main/expect/to/proper-extends.d.ts.map +1 -1
- package/esm/main/expect/to/proper-extends.js.map +1 -1
- package/esm/utils/logic/boolean.d.ts +60 -0
- package/esm/utils/logic/boolean.d.ts.map +1 -0
- package/esm/utils/logic/boolean.js +2 -0
- package/esm/utils/logic/boolean.js.map +1 -0
- package/esm/utils/logic/index.d.ts +1 -0
- package/esm/utils/logic/index.d.ts.map +1 -1
- package/esm/utils/logic/index.js +1 -0
- package/esm/utils/logic/index.js.map +1 -1
- package/package.json +1 -1
- package/script/main/expect/index.d.ts +1 -2
- package/script/main/expect/index.d.ts.map +1 -1
- package/script/main/expect/index.js.map +1 -1
- package/script/main/expect/to/be.d.ts +12 -12
- package/script/main/expect/to/be.d.ts.map +1 -1
- package/script/main/expect/to/be.js.map +1 -1
- package/script/main/expect/to/equal.d.ts +4 -4
- package/script/main/expect/to/equal.d.ts.map +1 -1
- package/script/main/expect/to/equal.js.map +1 -1
- package/script/main/expect/to/extend.d.ts +9 -9
- package/script/main/expect/to/extend.d.ts.map +1 -1
- package/script/main/expect/to/extend.js.map +1 -1
- package/script/main/expect/to/have-key.d.ts +6 -6
- package/script/main/expect/to/have-key.d.ts.map +1 -1
- package/script/main/expect/to/have-key.js.map +1 -1
- package/script/main/expect/to/index.d.ts +8 -6
- package/script/main/expect/to/index.d.ts.map +1 -1
- package/script/main/expect/to/index.js.map +1 -1
- package/script/main/expect/to/proper-extends.d.ts +4 -4
- package/script/main/expect/to/proper-extends.d.ts.map +1 -1
- package/script/main/expect/to/proper-extends.js.map +1 -1
- package/script/utils/logic/boolean.d.ts +60 -0
- package/script/utils/logic/boolean.d.ts.map +1 -0
- package/script/utils/logic/boolean.js +3 -0
- package/script/utils/logic/boolean.js.map +1 -0
- package/script/utils/logic/index.d.ts +1 -0
- package/script/utils/logic/index.d.ts.map +1 -1
- package/script/utils/logic/index.js +1 -0
- package/script/utils/logic/index.js.map +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Exact } from '../../utils/index.js';
|
|
2
1
|
import type { To } from './to/index.js';
|
|
3
2
|
/**
|
|
4
3
|
* Represents the result of a type assertion based on a boolean condition.
|
|
@@ -10,7 +9,7 @@ import type { To } from './to/index.js';
|
|
|
10
9
|
* @template B The boolean condition result (true or false)
|
|
11
10
|
* @template R The type of the result value (default is void)
|
|
12
11
|
*/
|
|
13
|
-
export type TypeAssertionResult<B extends boolean, R =
|
|
12
|
+
export type TypeAssertionResult<T, B extends boolean, R = ExpectType<T>> = [B] extends [true] ? {
|
|
14
13
|
/**
|
|
15
14
|
* This field exist only when this type assertion succeed
|
|
16
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/main/expect/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/main/expect/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAEvC;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,CAC7B,CAAC,EACD,CAAC,SAAS,OAAO,EACjB,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,IACf,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;IACrB;;;;OAIG;IACH,IAAI,EAAE,CAAC,CAAA;CACR,GACC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;IACpB;;;;OAIG;IACH,IAAI,EAAE,CAAC,CAAA;CACR,GACD,KAAK,CAAA;AAET,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;CACV,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/main/expect/index.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/main/expect/index.ts"],"names":[],"mappings":"","sourcesContent":["import type { To } from './to/index.js'\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n *\n * - If `true`, the result has a `pass` property;\n * - If `false`, the result has a `fail` property;\n * - Otherwise, the result is `never`\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\nexport type TypeAssertionResult<\n T,\n B extends boolean,\n R = ExpectType<T>,\n> = [B] extends [true] ? {\n /**\n * This field exist only when this type assertion succeed\n *\n * If you expect this assertion to fail, use `.fail`\n */\n pass: R\n }\n : [B] extends [false] ? {\n /**\n * This field exist only when this type assertion failed\n *\n * If you expect this assertion to pass, use `.pass`\n */\n fail: R\n }\n : never\n\nexport type ExpectType<T> = {\n to: To<T>\n}\n"]}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type { Exact, If } from '../../../utils/index.js';
|
|
1
|
+
import type { Exact, If, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
export type Be<T> = {
|
|
4
|
-
<U>(): TypeAssertionResult<Exact<T, U
|
|
5
|
-
<U>(_: U): TypeAssertionResult<Exact<T, U
|
|
6
|
-
} & If<Exact<T, any
|
|
3
|
+
export type Be<T, Inv extends boolean = false> = {
|
|
4
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, Exact<T, U>>>;
|
|
5
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, Exact<T, U>>>;
|
|
6
|
+
} & If<Xor<Inv, Exact<T, any>>, {
|
|
7
7
|
any: void;
|
|
8
|
-
}, {}> & If<Exact<T, never
|
|
8
|
+
}, {}> & If<Xor<Inv, Exact<T, never>>, {
|
|
9
9
|
never: void;
|
|
10
|
-
}, {}> & If<Exact<T, unknown
|
|
10
|
+
}, {}> & If<Xor<Inv, Exact<T, unknown>>, {
|
|
11
11
|
unknown: void;
|
|
12
|
-
}, {}> & If<Exact<T, void
|
|
12
|
+
}, {}> & If<Xor<Inv, Exact<T, void>>, {
|
|
13
13
|
void: void;
|
|
14
|
-
}, {}> & If<Exact<T, null
|
|
14
|
+
}, {}> & If<Xor<Inv, Exact<T, null>>, {
|
|
15
15
|
null: void;
|
|
16
|
-
}, {}> & If<Exact<T, undefined
|
|
16
|
+
}, {}> & If<Xor<Inv, Exact<T, undefined>>, {
|
|
17
17
|
undefined: void;
|
|
18
|
-
}, {}> & If<Exact<T, true
|
|
18
|
+
}, {}> & If<Xor<Inv, Exact<T, true>>, {
|
|
19
19
|
true: void;
|
|
20
|
-
}, {}> & If<Exact<T, false
|
|
20
|
+
}, {}> & If<Xor<Inv, Exact<T, false>>, {
|
|
21
21
|
false: void;
|
|
22
22
|
}, {}>;
|
|
23
23
|
//# sourceMappingURL=be.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"be.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/be.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"be.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/be.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IACzC;IACA,CAAC,CAAC,KAAK,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACpD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;CACzD,GACC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAC9C,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAClD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACtD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAChD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAChD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAC1D,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAChD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"be.js","sourceRoot":"","sources":["../../../../src/main/expect/to/be.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact, If } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Be<T> =\n & {\n <U>(): TypeAssertionResult<Exact<T, U
|
|
1
|
+
{"version":3,"file":"be.js","sourceRoot":"","sources":["../../../../src/main/expect/to/be.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact, If, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Be<T, Inv extends boolean = false> =\n & {\n <U>(): TypeAssertionResult<T, Xor<Inv, Exact<T, U>>>\n <U>(_: U): TypeAssertionResult<T, Xor<Inv, Exact<T, U>>>\n }\n & If<Xor<Inv, Exact<T, any>>, { any: void }, {}>\n & If<Xor<Inv, Exact<T, never>>, { never: void }, {}>\n & If<Xor<Inv, Exact<T, unknown>>, { unknown: void }, {}>\n & If<Xor<Inv, Exact<T, void>>, { void: void }, {}>\n & If<Xor<Inv, Exact<T, null>>, { null: void }, {}>\n & If<Xor<Inv, Exact<T, undefined>>, { undefined: void }, {}>\n & If<Xor<Inv, Exact<T, true>>, { true: void }, {}>\n & If<Xor<Inv, Exact<T, false>>, { false: void }, {}>\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { MutuallyAssignable } from '../../../utils/index.js';
|
|
1
|
+
import type { MutuallyAssignable, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
export type Equal<T> = {
|
|
3
|
+
export type Equal<T, Inv extends boolean = false> = {
|
|
4
4
|
/**
|
|
5
5
|
* Tests if the current type is mutually assignable with the provided type U.
|
|
6
6
|
*
|
|
@@ -20,7 +20,7 @@ export type Equal<T> = {
|
|
|
20
20
|
* expect<1>().to.equal<1 | 2>().fail
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
<U>(): TypeAssertionResult<MutuallyAssignable<T, U
|
|
24
|
-
<U>(_: U): TypeAssertionResult<MutuallyAssignable<T, U
|
|
23
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>;
|
|
24
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>;
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=equal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/equal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/equal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI;IAClD;;;;;;;;;;;;;;;;;;OAkBG;IACH,CAAC,CAAC,KAAK,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACjE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;CACtE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equal.js","sourceRoot":"","sources":["../../../../src/main/expect/to/equal.ts"],"names":[],"mappings":"","sourcesContent":["import type { MutuallyAssignable } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Equal<T> = {\n /**\n * Tests if the current type is mutually assignable with the provided type U.\n *\n * It's like:\n *\n * ```ts ignore\n * [T] extends [U] ? [U] extends [T] ? Yes : No : No\n * ```\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<{ a: 1; b: 2 }>().to.equal<{ a: 1 } & { b: 2 }>().pass\n * expect<1>().to.equal<1 | 2>().fail\n * ```\n */\n <U>(): TypeAssertionResult<MutuallyAssignable<T, U
|
|
1
|
+
{"version":3,"file":"equal.js","sourceRoot":"","sources":["../../../../src/main/expect/to/equal.ts"],"names":[],"mappings":"","sourcesContent":["import type { MutuallyAssignable, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Equal<T, Inv extends boolean = false> = {\n /**\n * Tests if the current type is mutually assignable with the provided type U.\n *\n * It's like:\n *\n * ```ts ignore\n * [T] extends [U] ? [U] extends [T] ? Yes : No : No\n * ```\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<{ a: 1; b: 2 }>().to.equal<{ a: 1 } & { b: 2 }>().pass\n * expect<1>().to.equal<1 | 2>().fail\n * ```\n */\n <U>(): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>\n <U>(_: U): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Extends, If } from '../../../utils/index.js';
|
|
1
|
+
import type { Extends, If, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
export type Extend<T> = {
|
|
3
|
+
export type Extend<T, Inv extends boolean = false> = {
|
|
4
4
|
/**
|
|
5
5
|
* Tests if the current type T extends the provided type U.
|
|
6
6
|
*
|
|
@@ -15,17 +15,17 @@ export type Extend<T> = {
|
|
|
15
15
|
* expect<'hello'>().to.extend<string>().pass
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
<U>(): TypeAssertionResult<Extends<T, U
|
|
19
|
-
<U>(_: U): TypeAssertionResult<Extends<T, U
|
|
20
|
-
} & If<Extends<T, number
|
|
18
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, Extends<T, U>>>;
|
|
19
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, Extends<T, U>>>;
|
|
20
|
+
} & If<Xor<Inv, Extends<T, number>>, {
|
|
21
21
|
number: void;
|
|
22
|
-
}, {}> & If<Extends<T, bigint
|
|
22
|
+
}, {}> & If<Xor<Inv, Extends<T, bigint>>, {
|
|
23
23
|
bigint: void;
|
|
24
|
-
}, {}> & If<Extends<T, string
|
|
24
|
+
}, {}> & If<Xor<Inv, Extends<T, string>>, {
|
|
25
25
|
string: void;
|
|
26
|
-
}, {}> & If<Extends<T, boolean
|
|
26
|
+
}, {}> & If<Xor<Inv, Extends<T, boolean>>, {
|
|
27
27
|
boolean: void;
|
|
28
|
-
}, {}> & If<Extends<T, symbol
|
|
28
|
+
}, {}> & If<Xor<Inv, Extends<T, symbol>>, {
|
|
29
29
|
symbol: void;
|
|
30
30
|
}, {}>;
|
|
31
31
|
//# sourceMappingURL=extend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/extend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/extend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAC7C;IACA;;;;;;;;;;;;;OAaG;IACH,CAAC,CAAC,KAAK,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACtD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;CAC3D,GACC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACtD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACtD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACtD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACxD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../../../../src/main/expect/to/extend.ts"],"names":[],"mappings":"","sourcesContent":["import type { Extends, If } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Extend<T> =\n & {\n /**\n * Tests if the current type T extends the provided type U.\n *\n * @template U The type to check extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().to.extend<number>().pass\n * expect<2>().to.extend<string>().fail\n * expect<'hello'>().to.extend<string>().pass\n * ```\n */\n <U>(): TypeAssertionResult<Extends<T, U
|
|
1
|
+
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../../../../src/main/expect/to/extend.ts"],"names":[],"mappings":"","sourcesContent":["import type { Extends, If, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Extend<T, Inv extends boolean = false> =\n & {\n /**\n * Tests if the current type T extends the provided type U.\n *\n * @template U The type to check extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().to.extend<number>().pass\n * expect<2>().to.extend<string>().fail\n * expect<'hello'>().to.extend<string>().pass\n * ```\n */\n <U>(): TypeAssertionResult<T, Xor<Inv, Extends<T, U>>>\n <U>(_: U): TypeAssertionResult<T, Xor<Inv, Extends<T, U>>>\n }\n & If<Xor<Inv, Extends<T, number>>, { number: void }, {}>\n & If<Xor<Inv, Extends<T, bigint>>, { bigint: void }, {}>\n & If<Xor<Inv, Extends<T, string>>, { string: void }, {}>\n & If<Xor<Inv, Extends<T, boolean>>, { boolean: void }, {}>\n & If<Xor<Inv, Extends<T, symbol>>, { symbol: void }, {}>\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Extends, IfTupleIncludes } from '../../../utils/index.js';
|
|
1
|
+
import type { Extends, IfTupleIncludes, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
type Result<T, K extends PropertyKey> = IfTupleIncludes<[
|
|
3
|
+
type Result<T, K extends PropertyKey, Inv extends boolean = false> = IfTupleIncludes<[
|
|
4
4
|
never,
|
|
5
5
|
any
|
|
6
|
-
], K, never, TypeAssertionResult<Extends<K, keyof T
|
|
7
|
-
export type HaveKey<T> = {
|
|
6
|
+
], K, never, TypeAssertionResult<T, Xor<Inv, Extends<K, keyof T>>>>;
|
|
7
|
+
export type HaveKey<T, Inv extends boolean = false> = {
|
|
8
8
|
/**
|
|
9
9
|
* Tests if the current type `T` has a property with key `K`.
|
|
10
10
|
*
|
|
@@ -31,8 +31,8 @@ export type HaveKey<T> = {
|
|
|
31
31
|
* expect<WithProp>().to.haveKey<'may' | 'unexist'>().fail
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
<K extends PropertyKey>(): Result<T, K>;
|
|
35
|
-
<K extends PropertyKey>(_: K): Result<T, K>;
|
|
34
|
+
<K extends PropertyKey>(): Result<T, K, Inv>;
|
|
35
|
+
<K extends PropertyKey>(_: K): Result<T, K, Inv>;
|
|
36
36
|
};
|
|
37
37
|
export {};
|
|
38
38
|
//# sourceMappingURL=have-key.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"have-key.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/have-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"have-key.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/have-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI,eAAe,CAClF;IAAC,KAAK;IAAE,GAAG;CAAC,EACZ,CAAC,EACD,KAAK,EACL,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CACtD,CAAA;AAED,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI;IACpD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,CAAC,CAAC,SAAS,WAAW,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5C,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;CACjD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"have-key.js","sourceRoot":"","sources":["../../../../src/main/expect/to/have-key.ts"],"names":[],"mappings":"","sourcesContent":["import type { Extends, IfTupleIncludes } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\ntype Result<T, K extends PropertyKey> = IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<Extends<K, keyof T
|
|
1
|
+
{"version":3,"file":"have-key.js","sourceRoot":"","sources":["../../../../src/main/expect/to/have-key.ts"],"names":[],"mappings":"","sourcesContent":["import type { Extends, IfTupleIncludes, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\ntype Result<T, K extends PropertyKey, Inv extends boolean = false> = IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<T, Xor<Inv, Extends<K, keyof T>>>\n>\n\nexport type HaveKey<T, Inv extends boolean = false> = {\n /**\n * Tests if the current type `T` has a property with key `K`.\n *\n * @template K The property key to check for\n *\n * ### Behavior\n *\n * - For single keys: succeeds if the key exists in `T`\n * - For union types: succeeds only if **all** keys in the union exist in `T`\n *\n * ### Examples\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * type WithProp = { prop: string; another: number; may?: 5 }\n *\n * // Single key checks\n * expect<WithProp>().to.haveKey<'prop'>().pass\n * expect<WithProp>().to.haveKey<'missing'>().fail\n *\n * // Union type checks\n * expect<WithProp>().to.haveKey<'prop' | 'another'>().pass\n * expect<WithProp>().to.haveKey<'may' | 'unexist'>().fail\n * ```\n */\n <K extends PropertyKey>(): Result<T, K, Inv>\n <K extends PropertyKey>(_: K): Result<T, K, Inv>\n}\n"]}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import type { Not } from '../../../utils/logic/boolean.js';
|
|
1
2
|
import type { Be } from './be.js';
|
|
2
3
|
import type { Equal } from './equal.js';
|
|
3
4
|
import type { Extend } from './extend.js';
|
|
4
5
|
import type { ProperExtends } from './proper-extends.js';
|
|
5
6
|
import type { HaveKey } from './have-key.js';
|
|
6
|
-
export type To<T> = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
export type To<T, Inv extends boolean = false> = {
|
|
8
|
+
not: To<T, Not<Inv>>;
|
|
9
|
+
be: Be<T, Inv>;
|
|
10
|
+
equal: Equal<T, Inv>;
|
|
11
|
+
extend: Extend<T, Inv>;
|
|
12
|
+
properExtend: ProperExtends<T, Inv>;
|
|
13
|
+
haveKey: HaveKey<T, Inv>;
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,MAAM,EAAE,CAAC,CAAC,IAAI;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AAC1D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI;IAC/C,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IACpB,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACd,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACpB,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACtB,YAAY,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACnC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;CACzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/main/expect/to/index.ts"],"names":[],"mappings":"","sourcesContent":["import type { Be } from './be.js'\nimport type { Equal } from './equal.js'\nimport type { Extend } from './extend.js'\nimport type { ProperExtends } from './proper-extends.js'\nimport type { HaveKey } from './have-key.js'\n\nexport type To<T> = {\n be: Be<T>\n equal: Equal<T>\n extend: Extend<T>\n properExtend: ProperExtends<T>\n haveKey: HaveKey<T>\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/main/expect/to/index.ts"],"names":[],"mappings":"","sourcesContent":["import type { Not } from '../../../utils/logic/boolean.js'\nimport type { Be } from './be.js'\nimport type { Equal } from './equal.js'\nimport type { Extend } from './extend.js'\nimport type { ProperExtends } from './proper-extends.js'\nimport type { HaveKey } from './have-key.js'\n\nexport type To<T, Inv extends boolean = false> = {\n not: To<T, Not<Inv>>\n be: Be<T, Inv>\n equal: Equal<T, Inv>\n extend: Extend<T, Inv>\n properExtend: ProperExtends<T, Inv>\n haveKey: HaveKey<T, Inv>\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ProperExtend } from '../../../utils/index.js';
|
|
1
|
+
import type { ProperExtend, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
export type ProperExtends<T> = {
|
|
3
|
+
export type ProperExtends<T, Inv extends boolean = false> = {
|
|
4
4
|
/**
|
|
5
5
|
* Tests if the current type T properly extends the provided type U (extends but is not the same).
|
|
6
6
|
*
|
|
@@ -15,7 +15,7 @@ export type ProperExtends<T> = {
|
|
|
15
15
|
* expect<number>().to.properExtend<number>().fail
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
<U>(): TypeAssertionResult<ProperExtend<T, U
|
|
19
|
-
<U>(_: U): TypeAssertionResult<ProperExtend<T, U
|
|
18
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>;
|
|
19
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>;
|
|
20
20
|
};
|
|
21
21
|
//# sourceMappingURL=proper-extends.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proper-extends.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/proper-extends.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"proper-extends.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/proper-extends.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI;IAC1D;;;;;;;;;;;;;OAaG;IACH,CAAC,CAAC,KAAK,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3D,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;CAChE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proper-extends.js","sourceRoot":"","sources":["../../../../src/main/expect/to/proper-extends.ts"],"names":[],"mappings":"","sourcesContent":["import type { ProperExtend } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type ProperExtends<T> = {\n /**\n * Tests if the current type T properly extends the provided type U (extends but is not the same).\n *\n * @template U The type to check proper extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<2>().to.properExtend<number>().pass\n * expect<'a' | 'b'>().to.properExtend<string>().pass\n * expect<number>().to.properExtend<number>().fail\n * ```\n */\n <U>(): TypeAssertionResult<ProperExtend<T, U
|
|
1
|
+
{"version":3,"file":"proper-extends.js","sourceRoot":"","sources":["../../../../src/main/expect/to/proper-extends.ts"],"names":[],"mappings":"","sourcesContent":["import type { ProperExtend, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type ProperExtends<T, Inv extends boolean = false> = {\n /**\n * Tests if the current type T properly extends the provided type U (extends but is not the same).\n *\n * @template U The type to check proper extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<2>().to.properExtend<number>().pass\n * expect<'a' | 'b'>().to.properExtend<string>().pass\n * expect<number>().to.properExtend<number>().fail\n * ```\n */\n <U>(): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>\n <U>(_: U): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Negates a boolean type
|
|
3
|
+
*
|
|
4
|
+
* @template T - The boolean type to negate
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { expect } from '@leawind/lay-sing'
|
|
9
|
+
*
|
|
10
|
+
* expect<Not<true>>().to.be.false
|
|
11
|
+
* expect<Not<false>>().to.be.true
|
|
12
|
+
* expect<Not<boolean>>().to.be<boolean>().pass
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export type Not<T extends boolean> = T extends true ? false : T extends false ? true : boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Logical AND operation on two boolean types
|
|
18
|
+
*
|
|
19
|
+
* @template A - The first boolean type to compare
|
|
20
|
+
* @template B - The second boolean type to compare
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { expect } from '@leawind/lay-sing'
|
|
25
|
+
*
|
|
26
|
+
* expect<And<true, true>>().to.be.true
|
|
27
|
+
* expect<And<true, false>>().to.be.false
|
|
28
|
+
* expect<And<false, true>>().to.be.false
|
|
29
|
+
* expect<And<false, false>>().to.be.false
|
|
30
|
+
* expect<And<boolean, boolean>>().to.be<boolean>().pass
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type And<A extends boolean, B extends boolean> = A extends never ? never : [B] extends [never] ? never : (A extends true ? (B extends true ? true : false) : false);
|
|
34
|
+
/**
|
|
35
|
+
* Logical OR operation on two boolean types
|
|
36
|
+
*
|
|
37
|
+
* @template A - The first boolean type to compare
|
|
38
|
+
* @template B - The second boolean type to compare
|
|
39
|
+
*
|
|
40
|
+
* ### Result
|
|
41
|
+
*
|
|
42
|
+
* - `never`: if either `A` or `B` is `never`
|
|
43
|
+
* - `boolean`: if either `A` or `B` is `boolean` or `any`
|
|
44
|
+
* - `false`: if both `A` and `B` are `false`
|
|
45
|
+
* - `true`: otherwise
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { expect } from '@leawind/lay-sing'
|
|
50
|
+
*
|
|
51
|
+
* expect<Or<true, true>>().to.be.true
|
|
52
|
+
* expect<Or<true, false>>().to.be.true
|
|
53
|
+
* expect<Or<false, true>>().to.be.true
|
|
54
|
+
* expect<Or<false, false>>().to.be.false
|
|
55
|
+
* expect<Or<boolean, false>>().to.be<boolean>().pass
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export type Or<A extends boolean, B extends boolean> = [A] extends [never] ? never : [B] extends [never] ? never : [boolean] extends [A] ? boolean : [boolean] extends [B] ? boolean : true extends A ? true : true extends B ? true : false;
|
|
59
|
+
export type Xor<A extends boolean, B extends boolean> = [A] extends [never] ? never : [B] extends [never] ? never : [boolean] extends [A] ? boolean : [boolean] extends [B] ? boolean : true extends A ? (true extends B ? false : true) : true extends B ? (true extends A ? false : true) : false;
|
|
60
|
+
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/boolean.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,IAAI,GAAG,KAAK,GACvD,CAAC,SAAS,KAAK,GAAG,IAAI,GACtB,OAAO,CAAA;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,GAAG,CACb,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,SAAS,KAAK,GAAG,KAAK,GACvB,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,EAAE,CACZ,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,KAAK,CAAA;AAET,MAAM,MAAM,GAAG,CACb,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,GAChD,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,GAChD,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../src/utils/logic/boolean.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Negates a boolean type\n *\n * @template T - The boolean type to negate\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<Not<true>>().to.be.false\n * expect<Not<false>>().to.be.true\n * expect<Not<boolean>>().to.be<boolean>().pass\n * ```\n */\nexport type Not<T extends boolean> = T extends true ? false\n : T extends false ? true\n : boolean\n\n/**\n * Logical AND operation on two boolean types\n *\n * @template A - The first boolean type to compare\n * @template B - The second boolean type to compare\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<And<true, true>>().to.be.true\n * expect<And<true, false>>().to.be.false\n * expect<And<false, true>>().to.be.false\n * expect<And<false, false>>().to.be.false\n * expect<And<boolean, boolean>>().to.be<boolean>().pass\n * ```\n */\nexport type And<\n A extends boolean,\n B extends boolean,\n> = A extends never ? never\n : [B] extends [never] ? never\n : (A extends true ? (B extends true ? true : false) : false)\n\n/**\n * Logical OR operation on two boolean types\n *\n * @template A - The first boolean type to compare\n * @template B - The second boolean type to compare\n *\n * ### Result\n *\n * - `never`: if either `A` or `B` is `never`\n * - `boolean`: if either `A` or `B` is `boolean` or `any`\n * - `false`: if both `A` and `B` are `false`\n * - `true`: otherwise\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<Or<true, true>>().to.be.true\n * expect<Or<true, false>>().to.be.true\n * expect<Or<false, true>>().to.be.true\n * expect<Or<false, false>>().to.be.false\n * expect<Or<boolean, false>>().to.be<boolean>().pass\n * ```\n */\nexport type Or<\n A extends boolean,\n B extends boolean,\n> = [A] extends [never] ? never\n : [B] extends [never] ? never\n : [boolean] extends [A] ? boolean\n : [boolean] extends [B] ? boolean\n : true extends A ? true\n : true extends B ? true\n : false\n\nexport type Xor<\n A extends boolean,\n B extends boolean,\n> = [A] extends [never] ? never\n : [B] extends [never] ? never\n : [boolean] extends [A] ? boolean\n : [boolean] extends [B] ? boolean\n : true extends A ? (true extends B ? false : true)\n : true extends B ? (true extends A ? false : true)\n : false\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA"}
|
package/esm/utils/logic/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,+BAA+B","sourcesContent":["// Index start >>>>>>>>>>>>>>>>\nexport * from './assert.js'\nexport * from './if.js'\nexport * from './switch.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,+BAA+B","sourcesContent":["// Index start >>>>>>>>>>>>>>>>\nexport * from './assert.js'\nexport * from './boolean.js'\nexport * from './if.js'\nexport * from './switch.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
|
package/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Exact } from '../../utils/index.js';
|
|
2
1
|
import type { To } from './to/index.js';
|
|
3
2
|
/**
|
|
4
3
|
* Represents the result of a type assertion based on a boolean condition.
|
|
@@ -10,7 +9,7 @@ import type { To } from './to/index.js';
|
|
|
10
9
|
* @template B The boolean condition result (true or false)
|
|
11
10
|
* @template R The type of the result value (default is void)
|
|
12
11
|
*/
|
|
13
|
-
export type TypeAssertionResult<B extends boolean, R =
|
|
12
|
+
export type TypeAssertionResult<T, B extends boolean, R = ExpectType<T>> = [B] extends [true] ? {
|
|
14
13
|
/**
|
|
15
14
|
* This field exist only when this type assertion succeed
|
|
16
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/main/expect/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/main/expect/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAEvC;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,CAC7B,CAAC,EACD,CAAC,SAAS,OAAO,EACjB,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,IACf,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;IACrB;;;;OAIG;IACH,IAAI,EAAE,CAAC,CAAA;CACR,GACC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;IACpB;;;;OAIG;IACH,IAAI,EAAE,CAAC,CAAA;CACR,GACD,KAAK,CAAA;AAET,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;CACV,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/main/expect/index.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/main/expect/index.ts"],"names":[],"mappings":"","sourcesContent":["import type { To } from './to/index.js'\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n *\n * - If `true`, the result has a `pass` property;\n * - If `false`, the result has a `fail` property;\n * - Otherwise, the result is `never`\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\nexport type TypeAssertionResult<\n T,\n B extends boolean,\n R = ExpectType<T>,\n> = [B] extends [true] ? {\n /**\n * This field exist only when this type assertion succeed\n *\n * If you expect this assertion to fail, use `.fail`\n */\n pass: R\n }\n : [B] extends [false] ? {\n /**\n * This field exist only when this type assertion failed\n *\n * If you expect this assertion to pass, use `.pass`\n */\n fail: R\n }\n : never\n\nexport type ExpectType<T> = {\n to: To<T>\n}\n"]}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type { Exact, If } from '../../../utils/index.js';
|
|
1
|
+
import type { Exact, If, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
export type Be<T> = {
|
|
4
|
-
<U>(): TypeAssertionResult<Exact<T, U
|
|
5
|
-
<U>(_: U): TypeAssertionResult<Exact<T, U
|
|
6
|
-
} & If<Exact<T, any
|
|
3
|
+
export type Be<T, Inv extends boolean = false> = {
|
|
4
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, Exact<T, U>>>;
|
|
5
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, Exact<T, U>>>;
|
|
6
|
+
} & If<Xor<Inv, Exact<T, any>>, {
|
|
7
7
|
any: void;
|
|
8
|
-
}, {}> & If<Exact<T, never
|
|
8
|
+
}, {}> & If<Xor<Inv, Exact<T, never>>, {
|
|
9
9
|
never: void;
|
|
10
|
-
}, {}> & If<Exact<T, unknown
|
|
10
|
+
}, {}> & If<Xor<Inv, Exact<T, unknown>>, {
|
|
11
11
|
unknown: void;
|
|
12
|
-
}, {}> & If<Exact<T, void
|
|
12
|
+
}, {}> & If<Xor<Inv, Exact<T, void>>, {
|
|
13
13
|
void: void;
|
|
14
|
-
}, {}> & If<Exact<T, null
|
|
14
|
+
}, {}> & If<Xor<Inv, Exact<T, null>>, {
|
|
15
15
|
null: void;
|
|
16
|
-
}, {}> & If<Exact<T, undefined
|
|
16
|
+
}, {}> & If<Xor<Inv, Exact<T, undefined>>, {
|
|
17
17
|
undefined: void;
|
|
18
|
-
}, {}> & If<Exact<T, true
|
|
18
|
+
}, {}> & If<Xor<Inv, Exact<T, true>>, {
|
|
19
19
|
true: void;
|
|
20
|
-
}, {}> & If<Exact<T, false
|
|
20
|
+
}, {}> & If<Xor<Inv, Exact<T, false>>, {
|
|
21
21
|
false: void;
|
|
22
22
|
}, {}>;
|
|
23
23
|
//# sourceMappingURL=be.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"be.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/be.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"be.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/be.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IACzC;IACA,CAAC,CAAC,KAAK,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACpD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;CACzD,GACC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAC9C,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAClD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACtD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAChD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAChD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAC1D,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GAChD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"be.js","sourceRoot":"","sources":["../../../../src/main/expect/to/be.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact, If } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Be<T> =\n & {\n <U>(): TypeAssertionResult<Exact<T, U
|
|
1
|
+
{"version":3,"file":"be.js","sourceRoot":"","sources":["../../../../src/main/expect/to/be.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact, If, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Be<T, Inv extends boolean = false> =\n & {\n <U>(): TypeAssertionResult<T, Xor<Inv, Exact<T, U>>>\n <U>(_: U): TypeAssertionResult<T, Xor<Inv, Exact<T, U>>>\n }\n & If<Xor<Inv, Exact<T, any>>, { any: void }, {}>\n & If<Xor<Inv, Exact<T, never>>, { never: void }, {}>\n & If<Xor<Inv, Exact<T, unknown>>, { unknown: void }, {}>\n & If<Xor<Inv, Exact<T, void>>, { void: void }, {}>\n & If<Xor<Inv, Exact<T, null>>, { null: void }, {}>\n & If<Xor<Inv, Exact<T, undefined>>, { undefined: void }, {}>\n & If<Xor<Inv, Exact<T, true>>, { true: void }, {}>\n & If<Xor<Inv, Exact<T, false>>, { false: void }, {}>\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { MutuallyAssignable } from '../../../utils/index.js';
|
|
1
|
+
import type { MutuallyAssignable, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
export type Equal<T> = {
|
|
3
|
+
export type Equal<T, Inv extends boolean = false> = {
|
|
4
4
|
/**
|
|
5
5
|
* Tests if the current type is mutually assignable with the provided type U.
|
|
6
6
|
*
|
|
@@ -20,7 +20,7 @@ export type Equal<T> = {
|
|
|
20
20
|
* expect<1>().to.equal<1 | 2>().fail
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
<U>(): TypeAssertionResult<MutuallyAssignable<T, U
|
|
24
|
-
<U>(_: U): TypeAssertionResult<MutuallyAssignable<T, U
|
|
23
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>;
|
|
24
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>;
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=equal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/equal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/equal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI;IAClD;;;;;;;;;;;;;;;;;;OAkBG;IACH,CAAC,CAAC,KAAK,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACjE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;CACtE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equal.js","sourceRoot":"","sources":["../../../../src/main/expect/to/equal.ts"],"names":[],"mappings":"","sourcesContent":["import type { MutuallyAssignable } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Equal<T> = {\n /**\n * Tests if the current type is mutually assignable with the provided type U.\n *\n * It's like:\n *\n * ```ts ignore\n * [T] extends [U] ? [U] extends [T] ? Yes : No : No\n * ```\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<{ a: 1; b: 2 }>().to.equal<{ a: 1 } & { b: 2 }>().pass\n * expect<1>().to.equal<1 | 2>().fail\n * ```\n */\n <U>(): TypeAssertionResult<MutuallyAssignable<T, U
|
|
1
|
+
{"version":3,"file":"equal.js","sourceRoot":"","sources":["../../../../src/main/expect/to/equal.ts"],"names":[],"mappings":"","sourcesContent":["import type { MutuallyAssignable, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Equal<T, Inv extends boolean = false> = {\n /**\n * Tests if the current type is mutually assignable with the provided type U.\n *\n * It's like:\n *\n * ```ts ignore\n * [T] extends [U] ? [U] extends [T] ? Yes : No : No\n * ```\n *\n * @template U The type to compare with\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<{ a: 1; b: 2 }>().to.equal<{ a: 1 } & { b: 2 }>().pass\n * expect<1>().to.equal<1 | 2>().fail\n * ```\n */\n <U>(): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>\n <U>(_: U): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Extends, If } from '../../../utils/index.js';
|
|
1
|
+
import type { Extends, If, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
export type Extend<T> = {
|
|
3
|
+
export type Extend<T, Inv extends boolean = false> = {
|
|
4
4
|
/**
|
|
5
5
|
* Tests if the current type T extends the provided type U.
|
|
6
6
|
*
|
|
@@ -15,17 +15,17 @@ export type Extend<T> = {
|
|
|
15
15
|
* expect<'hello'>().to.extend<string>().pass
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
<U>(): TypeAssertionResult<Extends<T, U
|
|
19
|
-
<U>(_: U): TypeAssertionResult<Extends<T, U
|
|
20
|
-
} & If<Extends<T, number
|
|
18
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, Extends<T, U>>>;
|
|
19
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, Extends<T, U>>>;
|
|
20
|
+
} & If<Xor<Inv, Extends<T, number>>, {
|
|
21
21
|
number: void;
|
|
22
|
-
}, {}> & If<Extends<T, bigint
|
|
22
|
+
}, {}> & If<Xor<Inv, Extends<T, bigint>>, {
|
|
23
23
|
bigint: void;
|
|
24
|
-
}, {}> & If<Extends<T, string
|
|
24
|
+
}, {}> & If<Xor<Inv, Extends<T, string>>, {
|
|
25
25
|
string: void;
|
|
26
|
-
}, {}> & If<Extends<T, boolean
|
|
26
|
+
}, {}> & If<Xor<Inv, Extends<T, boolean>>, {
|
|
27
27
|
boolean: void;
|
|
28
|
-
}, {}> & If<Extends<T, symbol
|
|
28
|
+
}, {}> & If<Xor<Inv, Extends<T, symbol>>, {
|
|
29
29
|
symbol: void;
|
|
30
30
|
}, {}>;
|
|
31
31
|
//# sourceMappingURL=extend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/extend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/extend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAC7C;IACA;;;;;;;;;;;;;OAaG;IACH,CAAC,CAAC,KAAK,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACtD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;CAC3D,GACC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACtD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACtD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACtD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,GACxD,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,EAAE,EAAE,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../../../../src/main/expect/to/extend.ts"],"names":[],"mappings":"","sourcesContent":["import type { Extends, If } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Extend<T> =\n & {\n /**\n * Tests if the current type T extends the provided type U.\n *\n * @template U The type to check extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().to.extend<number>().pass\n * expect<2>().to.extend<string>().fail\n * expect<'hello'>().to.extend<string>().pass\n * ```\n */\n <U>(): TypeAssertionResult<Extends<T, U
|
|
1
|
+
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../../../../src/main/expect/to/extend.ts"],"names":[],"mappings":"","sourcesContent":["import type { Extends, If, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type Extend<T, Inv extends boolean = false> =\n & {\n /**\n * Tests if the current type T extends the provided type U.\n *\n * @template U The type to check extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<3.14>().to.extend<number>().pass\n * expect<2>().to.extend<string>().fail\n * expect<'hello'>().to.extend<string>().pass\n * ```\n */\n <U>(): TypeAssertionResult<T, Xor<Inv, Extends<T, U>>>\n <U>(_: U): TypeAssertionResult<T, Xor<Inv, Extends<T, U>>>\n }\n & If<Xor<Inv, Extends<T, number>>, { number: void }, {}>\n & If<Xor<Inv, Extends<T, bigint>>, { bigint: void }, {}>\n & If<Xor<Inv, Extends<T, string>>, { string: void }, {}>\n & If<Xor<Inv, Extends<T, boolean>>, { boolean: void }, {}>\n & If<Xor<Inv, Extends<T, symbol>>, { symbol: void }, {}>\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Extends, IfTupleIncludes } from '../../../utils/index.js';
|
|
1
|
+
import type { Extends, IfTupleIncludes, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
type Result<T, K extends PropertyKey> = IfTupleIncludes<[
|
|
3
|
+
type Result<T, K extends PropertyKey, Inv extends boolean = false> = IfTupleIncludes<[
|
|
4
4
|
never,
|
|
5
5
|
any
|
|
6
|
-
], K, never, TypeAssertionResult<Extends<K, keyof T
|
|
7
|
-
export type HaveKey<T> = {
|
|
6
|
+
], K, never, TypeAssertionResult<T, Xor<Inv, Extends<K, keyof T>>>>;
|
|
7
|
+
export type HaveKey<T, Inv extends boolean = false> = {
|
|
8
8
|
/**
|
|
9
9
|
* Tests if the current type `T` has a property with key `K`.
|
|
10
10
|
*
|
|
@@ -31,8 +31,8 @@ export type HaveKey<T> = {
|
|
|
31
31
|
* expect<WithProp>().to.haveKey<'may' | 'unexist'>().fail
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
<K extends PropertyKey>(): Result<T, K>;
|
|
35
|
-
<K extends PropertyKey>(_: K): Result<T, K>;
|
|
34
|
+
<K extends PropertyKey>(): Result<T, K, Inv>;
|
|
35
|
+
<K extends PropertyKey>(_: K): Result<T, K, Inv>;
|
|
36
36
|
};
|
|
37
37
|
export {};
|
|
38
38
|
//# sourceMappingURL=have-key.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"have-key.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/have-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"have-key.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/have-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI,eAAe,CAClF;IAAC,KAAK;IAAE,GAAG;CAAC,EACZ,CAAC,EACD,KAAK,EACL,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CACtD,CAAA;AAED,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI;IACpD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,CAAC,CAAC,SAAS,WAAW,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;IAC5C,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;CACjD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"have-key.js","sourceRoot":"","sources":["../../../../src/main/expect/to/have-key.ts"],"names":[],"mappings":"","sourcesContent":["import type { Extends, IfTupleIncludes } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\ntype Result<T, K extends PropertyKey> = IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<Extends<K, keyof T
|
|
1
|
+
{"version":3,"file":"have-key.js","sourceRoot":"","sources":["../../../../src/main/expect/to/have-key.ts"],"names":[],"mappings":"","sourcesContent":["import type { Extends, IfTupleIncludes, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\ntype Result<T, K extends PropertyKey, Inv extends boolean = false> = IfTupleIncludes<\n [never, any],\n K,\n never,\n TypeAssertionResult<T, Xor<Inv, Extends<K, keyof T>>>\n>\n\nexport type HaveKey<T, Inv extends boolean = false> = {\n /**\n * Tests if the current type `T` has a property with key `K`.\n *\n * @template K The property key to check for\n *\n * ### Behavior\n *\n * - For single keys: succeeds if the key exists in `T`\n * - For union types: succeeds only if **all** keys in the union exist in `T`\n *\n * ### Examples\n *\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * type WithProp = { prop: string; another: number; may?: 5 }\n *\n * // Single key checks\n * expect<WithProp>().to.haveKey<'prop'>().pass\n * expect<WithProp>().to.haveKey<'missing'>().fail\n *\n * // Union type checks\n * expect<WithProp>().to.haveKey<'prop' | 'another'>().pass\n * expect<WithProp>().to.haveKey<'may' | 'unexist'>().fail\n * ```\n */\n <K extends PropertyKey>(): Result<T, K, Inv>\n <K extends PropertyKey>(_: K): Result<T, K, Inv>\n}\n"]}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import type { Not } from '../../../utils/logic/boolean.js';
|
|
1
2
|
import type { Be } from './be.js';
|
|
2
3
|
import type { Equal } from './equal.js';
|
|
3
4
|
import type { Extend } from './extend.js';
|
|
4
5
|
import type { ProperExtends } from './proper-extends.js';
|
|
5
6
|
import type { HaveKey } from './have-key.js';
|
|
6
|
-
export type To<T> = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
export type To<T, Inv extends boolean = false> = {
|
|
8
|
+
not: To<T, Not<Inv>>;
|
|
9
|
+
be: Be<T, Inv>;
|
|
10
|
+
equal: Equal<T, Inv>;
|
|
11
|
+
extend: Extend<T, Inv>;
|
|
12
|
+
properExtend: ProperExtends<T, Inv>;
|
|
13
|
+
haveKey: HaveKey<T, Inv>;
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,MAAM,EAAE,CAAC,CAAC,IAAI;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AAC1D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI;IAC/C,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IACpB,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACd,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACpB,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACtB,YAAY,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACnC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;CACzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/main/expect/to/index.ts"],"names":[],"mappings":"","sourcesContent":["import type { Be } from './be.js'\nimport type { Equal } from './equal.js'\nimport type { Extend } from './extend.js'\nimport type { ProperExtends } from './proper-extends.js'\nimport type { HaveKey } from './have-key.js'\n\nexport type To<T> = {\n be: Be<T>\n equal: Equal<T>\n extend: Extend<T>\n properExtend: ProperExtends<T>\n haveKey: HaveKey<T>\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/main/expect/to/index.ts"],"names":[],"mappings":"","sourcesContent":["import type { Not } from '../../../utils/logic/boolean.js'\nimport type { Be } from './be.js'\nimport type { Equal } from './equal.js'\nimport type { Extend } from './extend.js'\nimport type { ProperExtends } from './proper-extends.js'\nimport type { HaveKey } from './have-key.js'\n\nexport type To<T, Inv extends boolean = false> = {\n not: To<T, Not<Inv>>\n be: Be<T, Inv>\n equal: Equal<T, Inv>\n extend: Extend<T, Inv>\n properExtend: ProperExtends<T, Inv>\n haveKey: HaveKey<T, Inv>\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ProperExtend } from '../../../utils/index.js';
|
|
1
|
+
import type { ProperExtend, Xor } from '../../../utils/index.js';
|
|
2
2
|
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
-
export type ProperExtends<T> = {
|
|
3
|
+
export type ProperExtends<T, Inv extends boolean = false> = {
|
|
4
4
|
/**
|
|
5
5
|
* Tests if the current type T properly extends the provided type U (extends but is not the same).
|
|
6
6
|
*
|
|
@@ -15,7 +15,7 @@ export type ProperExtends<T> = {
|
|
|
15
15
|
* expect<number>().to.properExtend<number>().fail
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
<U>(): TypeAssertionResult<ProperExtend<T, U
|
|
19
|
-
<U>(_: U): TypeAssertionResult<ProperExtend<T, U
|
|
18
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>;
|
|
19
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>;
|
|
20
20
|
};
|
|
21
21
|
//# sourceMappingURL=proper-extends.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proper-extends.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/proper-extends.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"proper-extends.d.ts","sourceRoot":"","sources":["../../../../src/main/expect/to/proper-extends.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,GAAG,SAAS,OAAO,GAAG,KAAK,IAAI;IAC1D;;;;;;;;;;;;;OAaG;IACH,CAAC,CAAC,KAAK,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3D,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;CAChE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proper-extends.js","sourceRoot":"","sources":["../../../../src/main/expect/to/proper-extends.ts"],"names":[],"mappings":"","sourcesContent":["import type { ProperExtend } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type ProperExtends<T> = {\n /**\n * Tests if the current type T properly extends the provided type U (extends but is not the same).\n *\n * @template U The type to check proper extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<2>().to.properExtend<number>().pass\n * expect<'a' | 'b'>().to.properExtend<string>().pass\n * expect<number>().to.properExtend<number>().fail\n * ```\n */\n <U>(): TypeAssertionResult<ProperExtend<T, U
|
|
1
|
+
{"version":3,"file":"proper-extends.js","sourceRoot":"","sources":["../../../../src/main/expect/to/proper-extends.ts"],"names":[],"mappings":"","sourcesContent":["import type { ProperExtend, Xor } from '../../../utils/index.js'\nimport type { TypeAssertionResult } from '../index.js'\n\nexport type ProperExtends<T, Inv extends boolean = false> = {\n /**\n * Tests if the current type T properly extends the provided type U (extends but is not the same).\n *\n * @template U The type to check proper extension against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<2>().to.properExtend<number>().pass\n * expect<'a' | 'b'>().to.properExtend<string>().pass\n * expect<number>().to.properExtend<number>().fail\n * ```\n */\n <U>(): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>\n <U>(_: U): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Negates a boolean type
|
|
3
|
+
*
|
|
4
|
+
* @template T - The boolean type to negate
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { expect } from '@leawind/lay-sing'
|
|
9
|
+
*
|
|
10
|
+
* expect<Not<true>>().to.be.false
|
|
11
|
+
* expect<Not<false>>().to.be.true
|
|
12
|
+
* expect<Not<boolean>>().to.be<boolean>().pass
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export type Not<T extends boolean> = T extends true ? false : T extends false ? true : boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Logical AND operation on two boolean types
|
|
18
|
+
*
|
|
19
|
+
* @template A - The first boolean type to compare
|
|
20
|
+
* @template B - The second boolean type to compare
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { expect } from '@leawind/lay-sing'
|
|
25
|
+
*
|
|
26
|
+
* expect<And<true, true>>().to.be.true
|
|
27
|
+
* expect<And<true, false>>().to.be.false
|
|
28
|
+
* expect<And<false, true>>().to.be.false
|
|
29
|
+
* expect<And<false, false>>().to.be.false
|
|
30
|
+
* expect<And<boolean, boolean>>().to.be<boolean>().pass
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type And<A extends boolean, B extends boolean> = A extends never ? never : [B] extends [never] ? never : (A extends true ? (B extends true ? true : false) : false);
|
|
34
|
+
/**
|
|
35
|
+
* Logical OR operation on two boolean types
|
|
36
|
+
*
|
|
37
|
+
* @template A - The first boolean type to compare
|
|
38
|
+
* @template B - The second boolean type to compare
|
|
39
|
+
*
|
|
40
|
+
* ### Result
|
|
41
|
+
*
|
|
42
|
+
* - `never`: if either `A` or `B` is `never`
|
|
43
|
+
* - `boolean`: if either `A` or `B` is `boolean` or `any`
|
|
44
|
+
* - `false`: if both `A` and `B` are `false`
|
|
45
|
+
* - `true`: otherwise
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { expect } from '@leawind/lay-sing'
|
|
50
|
+
*
|
|
51
|
+
* expect<Or<true, true>>().to.be.true
|
|
52
|
+
* expect<Or<true, false>>().to.be.true
|
|
53
|
+
* expect<Or<false, true>>().to.be.true
|
|
54
|
+
* expect<Or<false, false>>().to.be.false
|
|
55
|
+
* expect<Or<boolean, false>>().to.be<boolean>().pass
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export type Or<A extends boolean, B extends boolean> = [A] extends [never] ? never : [B] extends [never] ? never : [boolean] extends [A] ? boolean : [boolean] extends [B] ? boolean : true extends A ? true : true extends B ? true : false;
|
|
59
|
+
export type Xor<A extends boolean, B extends boolean> = [A] extends [never] ? never : [B] extends [never] ? never : [boolean] extends [A] ? boolean : [boolean] extends [B] ? boolean : true extends A ? (true extends B ? false : true) : true extends B ? (true extends A ? false : true) : false;
|
|
60
|
+
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/boolean.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,IAAI,GAAG,KAAK,GACvD,CAAC,SAAS,KAAK,GAAG,IAAI,GACtB,OAAO,CAAA;AAEX;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,GAAG,CACb,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,SAAS,KAAK,GAAG,KAAK,GACvB,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,EAAE,CACZ,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,IAAI,SAAS,CAAC,GAAG,IAAI,GACrB,KAAK,CAAA;AAET,MAAM,MAAM,GAAG,CACb,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,IACf,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,GAC3B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,GAC/B,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,GAChD,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,GAChD,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../src/utils/logic/boolean.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Negates a boolean type\n *\n * @template T - The boolean type to negate\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<Not<true>>().to.be.false\n * expect<Not<false>>().to.be.true\n * expect<Not<boolean>>().to.be<boolean>().pass\n * ```\n */\nexport type Not<T extends boolean> = T extends true ? false\n : T extends false ? true\n : boolean\n\n/**\n * Logical AND operation on two boolean types\n *\n * @template A - The first boolean type to compare\n * @template B - The second boolean type to compare\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<And<true, true>>().to.be.true\n * expect<And<true, false>>().to.be.false\n * expect<And<false, true>>().to.be.false\n * expect<And<false, false>>().to.be.false\n * expect<And<boolean, boolean>>().to.be<boolean>().pass\n * ```\n */\nexport type And<\n A extends boolean,\n B extends boolean,\n> = A extends never ? never\n : [B] extends [never] ? never\n : (A extends true ? (B extends true ? true : false) : false)\n\n/**\n * Logical OR operation on two boolean types\n *\n * @template A - The first boolean type to compare\n * @template B - The second boolean type to compare\n *\n * ### Result\n *\n * - `never`: if either `A` or `B` is `never`\n * - `boolean`: if either `A` or `B` is `boolean` or `any`\n * - `false`: if both `A` and `B` are `false`\n * - `true`: otherwise\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<Or<true, true>>().to.be.true\n * expect<Or<true, false>>().to.be.true\n * expect<Or<false, true>>().to.be.true\n * expect<Or<false, false>>().to.be.false\n * expect<Or<boolean, false>>().to.be<boolean>().pass\n * ```\n */\nexport type Or<\n A extends boolean,\n B extends boolean,\n> = [A] extends [never] ? never\n : [B] extends [never] ? never\n : [boolean] extends [A] ? boolean\n : [boolean] extends [B] ? boolean\n : true extends A ? true\n : true extends B ? true\n : false\n\nexport type Xor<\n A extends boolean,\n B extends boolean,\n> = [A] extends [never] ? never\n : [B] extends [never] ? never\n : [boolean] extends [A] ? boolean\n : [boolean] extends [B] ? boolean\n : true extends A ? (true extends B ? false : true)\n : true extends B ? (true extends A ? false : true)\n : false\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA"}
|
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
// Index start >>>>>>>>>>>>>>>>
|
|
18
18
|
__exportStar(require("./assert.js"), exports);
|
|
19
|
+
__exportStar(require("./boolean.js"), exports);
|
|
19
20
|
__exportStar(require("./if.js"), exports);
|
|
20
21
|
__exportStar(require("./switch.js"), exports);
|
|
21
22
|
// <<<<<<<<<<<<<<<< Index end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,8CAA2B;AAC3B,0CAAuB;AACvB,8CAA2B;AAC3B,+BAA+B","sourcesContent":["// Index start >>>>>>>>>>>>>>>>\nexport * from './assert.js'\nexport * from './if.js'\nexport * from './switch.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/logic/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,8CAA2B;AAC3B,+CAA4B;AAC5B,0CAAuB;AACvB,8CAA2B;AAC3B,+BAA+B","sourcesContent":["// Index start >>>>>>>>>>>>>>>>\nexport * from './assert.js'\nexport * from './boolean.js'\nexport * from './if.js'\nexport * from './switch.js'\n// <<<<<<<<<<<<<<<< Index end\n"]}
|