lay-sing 0.3.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/README.md +17 -17
- package/esm/main/expect/index.d.ts +30 -0
- package/esm/main/expect/index.d.ts.map +1 -0
- package/esm/main/expect/index.js +2 -0
- package/esm/main/expect/index.js.map +1 -0
- package/esm/main/expect/to/be.d.ts +23 -0
- package/esm/main/expect/to/be.d.ts.map +1 -0
- package/esm/main/expect/to/be.js +2 -0
- package/esm/main/expect/to/be.js.map +1 -0
- package/esm/main/expect/to/equal.d.ts +26 -0
- package/esm/main/expect/to/equal.d.ts.map +1 -0
- package/esm/main/expect/to/equal.js +2 -0
- package/esm/main/expect/to/equal.js.map +1 -0
- package/esm/main/expect/to/extend.d.ts +31 -0
- package/esm/main/expect/to/extend.d.ts.map +1 -0
- package/esm/main/expect/to/extend.js +2 -0
- package/esm/main/expect/to/extend.js.map +1 -0
- package/esm/main/expect/to/have-key.d.ts +38 -0
- package/esm/main/expect/to/have-key.d.ts.map +1 -0
- package/esm/main/expect/to/have-key.js +2 -0
- package/esm/main/expect/to/have-key.js.map +1 -0
- package/esm/main/expect/to/index.d.ts +15 -0
- package/esm/main/expect/to/index.d.ts.map +1 -0
- package/esm/main/expect/to/index.js +2 -0
- package/esm/main/expect/to/index.js.map +1 -0
- package/esm/main/expect/to/proper-extends.d.ts +21 -0
- package/esm/main/expect/to/proper-extends.d.ts.map +1 -0
- package/esm/main/expect/to/proper-extends.js +2 -0
- package/esm/main/expect/to/proper-extends.js.map +1 -0
- package/esm/main/index.d.ts +10 -8
- package/esm/main/index.d.ts.map +1 -1
- package/esm/main/index.js +20 -3
- package/esm/main/index.js.map +1 -1
- package/esm/utils/compare/exact.d.ts +8 -8
- package/esm/utils/compare/exact.js.map +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/logic/assert.d.ts +3 -3
- package/esm/utils/logic/assert.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/esm/utils/logic/switch.d.ts +1 -1
- package/esm/utils/logic/switch.js.map +1 -1
- package/esm/utils/misc.d.ts +34 -0
- package/esm/utils/misc.d.ts.map +1 -0
- package/esm/utils/misc.js +2 -0
- package/esm/utils/misc.js.map +1 -0
- package/esm/utils/object/keys.d.ts +12 -12
- package/esm/utils/object/keys.js.map +1 -1
- package/esm/utils/object/pick.d.ts +1 -1
- package/esm/utils/object/pick.js.map +1 -1
- package/esm/utils/object/props.d.ts +1 -1
- package/esm/utils/object/props.js.map +1 -1
- package/esm/utils/tuple/append.d.ts +2 -2
- package/esm/utils/tuple/append.js.map +1 -1
- package/esm/utils/tuple/concat.d.ts +2 -2
- package/esm/utils/tuple/concat.js.map +1 -1
- package/esm/utils/tuple/includes.d.ts +3 -3
- package/esm/utils/tuple/includes.js.map +1 -1
- package/package.json +1 -1
- package/script/main/expect/index.d.ts +30 -0
- package/script/main/expect/index.d.ts.map +1 -0
- package/script/main/{expect.js → expect/index.js} +1 -1
- package/script/main/expect/index.js.map +1 -0
- package/script/main/expect/to/be.d.ts +23 -0
- package/script/main/expect/to/be.d.ts.map +1 -0
- package/script/main/expect/to/be.js +3 -0
- package/script/main/expect/to/be.js.map +1 -0
- package/script/main/expect/to/equal.d.ts +26 -0
- package/script/main/expect/to/equal.d.ts.map +1 -0
- package/script/main/expect/to/equal.js +3 -0
- package/script/main/expect/to/equal.js.map +1 -0
- package/script/main/expect/to/extend.d.ts +31 -0
- package/script/main/expect/to/extend.d.ts.map +1 -0
- package/script/main/expect/to/extend.js +3 -0
- package/script/main/expect/to/extend.js.map +1 -0
- package/script/main/expect/to/have-key.d.ts +38 -0
- package/script/main/expect/to/have-key.d.ts.map +1 -0
- package/script/main/expect/to/have-key.js +3 -0
- package/script/main/expect/to/have-key.js.map +1 -0
- package/script/main/expect/to/index.d.ts +15 -0
- package/script/main/expect/to/index.d.ts.map +1 -0
- package/script/main/expect/to/index.js +3 -0
- package/script/main/expect/to/index.js.map +1 -0
- package/script/main/expect/to/proper-extends.d.ts +21 -0
- package/script/main/expect/to/proper-extends.d.ts.map +1 -0
- package/script/main/expect/to/proper-extends.js +3 -0
- package/script/main/expect/to/proper-extends.js.map +1 -0
- package/script/main/index.d.ts +10 -8
- package/script/main/index.d.ts.map +1 -1
- package/script/main/index.js +21 -5
- package/script/main/index.js.map +1 -1
- package/script/utils/compare/exact.d.ts +8 -8
- package/script/utils/compare/exact.js.map +1 -1
- package/script/utils/index.d.ts +1 -0
- package/script/utils/index.d.ts.map +1 -1
- package/script/utils/index.js +1 -0
- package/script/utils/index.js.map +1 -1
- package/script/utils/logic/assert.d.ts +3 -3
- package/script/utils/logic/assert.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
- package/script/utils/logic/switch.d.ts +1 -1
- package/script/utils/logic/switch.js.map +1 -1
- package/script/utils/misc.d.ts +34 -0
- package/script/utils/misc.d.ts.map +1 -0
- package/script/utils/misc.js +3 -0
- package/script/utils/misc.js.map +1 -0
- package/script/utils/object/keys.d.ts +12 -12
- package/script/utils/object/keys.js.map +1 -1
- package/script/utils/object/pick.d.ts +1 -1
- package/script/utils/object/pick.js.map +1 -1
- package/script/utils/object/props.d.ts +1 -1
- package/script/utils/object/props.js.map +1 -1
- package/script/utils/tuple/append.d.ts +2 -2
- package/script/utils/tuple/append.js.map +1 -1
- package/script/utils/tuple/concat.d.ts +2 -2
- package/script/utils/tuple/concat.js.map +1 -1
- package/script/utils/tuple/includes.d.ts +3 -3
- package/script/utils/tuple/includes.js.map +1 -1
- package/esm/main/expect.d.ts +0 -293
- package/esm/main/expect.d.ts.map +0 -1
- package/esm/main/expect.js +0 -2
- package/esm/main/expect.js.map +0 -1
- package/script/main/expect.d.ts +0 -293
- package/script/main/expect.d.ts.map +0 -1
- package/script/main/expect.js.map +0 -1
|
@@ -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"]}
|
|
@@ -80,7 +80,7 @@ export type SwitchExact<T, Cases extends readonly [unknown, unknown][], Default
|
|
|
80
80
|
* [number, boolean],
|
|
81
81
|
* [string, boolean],
|
|
82
82
|
* ], Error>
|
|
83
|
-
* >().
|
|
83
|
+
* >().to.be<boolean>().pass
|
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
86
|
export type SwitchExtends<T, Cases extends readonly [unknown, unknown][], Default = never> = Cases extends [infer First, ...infer Rest] ? (First extends [infer C, infer R] ? ([T] extends [C] ? R : SwitchExtends<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>) : never) : Default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/utils/logic/switch.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from '../index.js'\n\n/**\n * Case tuple type used with `SwitchExact` and `SwitchExtends`\n *\n * @template T - The condition type to match against\n * @template Result - The result type to return if match is found\n *\n * @example\n * ```ts\n * type MyCase = Case<1, 'one'>\n * // Equivalent to: [1, 'one']\n * ```\n *\n * @example\n * ```ts\n * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'\n * type NameMap<id> = SwitchExact<id, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * ], DefaultCase<'Steve'>>\n * ```\n *\n * @see SwitchExact\n */\nexport type Case<T = unknown, Result = unknown> = [T, Result]\n\n/**\n * Default case type used with `SwitchExact` and `SwitchExtends`\n *\n * @template T - The default result type\n *\n * @example\n * ```ts\n * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'\n * type NameMap<id> = SwitchExact<id, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * ], DefaultCase<'Steve'>>\n * ```\n *\n * @see SwitchExact\n */\nexport type DefaultCase<T> = T\n\n/**\n * Switch type that uses exact matching logic\n *\n * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.\n *\n * @template T - The type to match against cases\n * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]\n * @template Default - Default result if no exact match is found (defaults to `never`)\n *\n * @example\n * ```ts\n * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'\n * type Result = SwitchExact<2, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * [3, 'Charlie'],\n * ], DefaultCase<'Steve'>>\n *\n * // Result: 'Bob'\n * ```\n */\nexport type SwitchExact<\n T,\n Cases extends readonly [unknown, unknown][],\n Default = never,\n> = Cases extends [infer First, ...infer Rest] ? (\n First extends [infer Condition, infer Result] ? (Exact<T, Condition> extends true ? Result\n : (SwitchExact<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>))\n : (never)\n )\n : Default\n\n/**\n * Switch type that uses 'extends' logic instead of 'Exact' logic\n *\n * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.\n *\n * @template T - The type to match against cases\n * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]\n * @template Default - Default result if no match is found (defaults to `never`)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<\n * SwitchExtends<string, [\n * [number, boolean],\n * [string, boolean],\n * ], Error>\n * >().
|
|
1
|
+
{"version":3,"file":"switch.js","sourceRoot":"","sources":["../../../src/utils/logic/switch.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from '../index.js'\n\n/**\n * Case tuple type used with `SwitchExact` and `SwitchExtends`\n *\n * @template T - The condition type to match against\n * @template Result - The result type to return if match is found\n *\n * @example\n * ```ts\n * type MyCase = Case<1, 'one'>\n * // Equivalent to: [1, 'one']\n * ```\n *\n * @example\n * ```ts\n * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'\n * type NameMap<id> = SwitchExact<id, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * ], DefaultCase<'Steve'>>\n * ```\n *\n * @see SwitchExact\n */\nexport type Case<T = unknown, Result = unknown> = [T, Result]\n\n/**\n * Default case type used with `SwitchExact` and `SwitchExtends`\n *\n * @template T - The default result type\n *\n * @example\n * ```ts\n * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'\n * type NameMap<id> = SwitchExact<id, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * ], DefaultCase<'Steve'>>\n * ```\n *\n * @see SwitchExact\n */\nexport type DefaultCase<T> = T\n\n/**\n * Switch type that uses exact matching logic\n *\n * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.\n *\n * @template T - The type to match against cases\n * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]\n * @template Default - Default result if no exact match is found (defaults to `never`)\n *\n * @example\n * ```ts\n * import { SwitchExact, DefaultCase } from '@leawind/lay-sing/utils'\n * type Result = SwitchExact<2, [\n * [1, 'Alice'],\n * [2, 'Bob'],\n * [3, 'Charlie'],\n * ], DefaultCase<'Steve'>>\n *\n * // Result: 'Bob'\n * ```\n */\nexport type SwitchExact<\n T,\n Cases extends readonly [unknown, unknown][],\n Default = never,\n> = Cases extends [infer First, ...infer Rest] ? (\n First extends [infer Condition, infer Result] ? (Exact<T, Condition> extends true ? Result\n : (SwitchExact<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>))\n : (never)\n )\n : Default\n\n/**\n * Switch type that uses 'extends' logic instead of 'Exact' logic\n *\n * **⚠️Important:** `T` parameter is not distributive. When `T` is a union type, it does not check each member separately.\n *\n * @template T - The type to match against cases\n * @template Cases - Array of case tuples, each tuple has the form [Condition, Result]\n * @template Default - Default result if no match is found (defaults to `never`)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<\n * SwitchExtends<string, [\n * [number, boolean],\n * [string, boolean],\n * ], Error>\n * >().to.be<boolean>().pass\n * ```\n */\nexport type SwitchExtends<\n T,\n Cases extends readonly [unknown, unknown][],\n Default = never,\n> = Cases extends [infer First, ...infer Rest] ? (\n First extends [infer C, infer R]\n ? ([T] extends [C] ? R : SwitchExtends<T, Rest extends readonly [unknown, unknown][] ? Rest : never, Default>)\n : never\n )\n : Default\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an intersection of all types in the provided tuple
|
|
3
|
+
*
|
|
4
|
+
* ## `IntersectionOf<[A, B, ... T]>` = `A & B & ... & T`
|
|
5
|
+
*
|
|
6
|
+
* @template Types - A tuple of types to create an intersection from
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { expect } from '@leawind/lay-sing'
|
|
11
|
+
*
|
|
12
|
+
* type Result = IntersectionOf<[{ a: string }, { b: number }, { c: boolean }]>
|
|
13
|
+
* expect<Result>().to.extend<{ a: string } & { b: number } & { c: boolean }>().pass
|
|
14
|
+
* expect<Result>().to.extend<{ a: string; b: number; c: boolean }>().pass
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export type IntersectionOf<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest] ? First & IntersectionOf<Rest> : unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a union of all types in the provided tuple
|
|
20
|
+
*
|
|
21
|
+
* ## `UnionOf<[A, B, ... T]>` = `A | B | ... | T`
|
|
22
|
+
*
|
|
23
|
+
* @template Types - A tuple of types to create a union from
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { expect } from '@leawind/lay-sing'
|
|
28
|
+
*
|
|
29
|
+
* type Result = UnionOf<[string, number, boolean]>
|
|
30
|
+
* expect<Result>().to.be<string | number | boolean>().pass
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type UnionOf<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest] ? First | UnionOf<Rest> : never;
|
|
34
|
+
//# sourceMappingURL=misc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GACrG,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,GAC5B,OAAO,CAAA;AAEX;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAC9F,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,GACrB,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Creates an intersection of all types in the provided tuple\n *\n * ## `IntersectionOf<[A, B, ... T]>` = `A & B & ... & T`\n *\n * @template Types - A tuple of types to create an intersection from\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * type Result = IntersectionOf<[{ a: string }, { b: number }, { c: boolean }]>\n * expect<Result>().to.extend<{ a: string } & { b: number } & { c: boolean }>().pass\n * expect<Result>().to.extend<{ a: string; b: number; c: boolean }>().pass\n * ```\n */\nexport type IntersectionOf<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest]\n ? First & IntersectionOf<Rest>\n : unknown\n\n/**\n * Creates a union of all types in the provided tuple\n *\n * ## `UnionOf<[A, B, ... T]>` = `A | B | ... | T`\n *\n * @template Types - A tuple of types to create a union from\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * type Result = UnionOf<[string, number, boolean]>\n * expect<Result>().to.be<string | number | boolean>().pass\n * ```\n */\nexport type UnionOf<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest]\n ? First | UnionOf<Rest>\n : never\n"]}
|
|
@@ -14,17 +14,17 @@ import type { Exact } from '../index.js';
|
|
|
14
14
|
*
|
|
15
15
|
* // Basic usage: match exact type (non-optional property)
|
|
16
16
|
* type A = { a: 1; b: 2; c: 1 };
|
|
17
|
-
* expect<KeysOfExactType<A, 1>>().
|
|
17
|
+
* expect<KeysOfExactType<A, 1>>().to.be<'a' | 'c'>().pass
|
|
18
18
|
*
|
|
19
19
|
* // Key difference: optional property matching (requires undefined in `ValueType`)
|
|
20
20
|
* type B = { a?: string };
|
|
21
|
-
* expect<KeysOfExactType<B, string | undefined>>().
|
|
22
|
-
* expect<KeysOfExactType<B, string>>().
|
|
21
|
+
* expect<KeysOfExactType<B, string | undefined>>().to.be<'a'>().pass // matches complete type
|
|
22
|
+
* expect<KeysOfExactType<B, string>>().to.be<never>().pass // does not match complete type
|
|
23
23
|
*
|
|
24
24
|
* type C = { a: never; b: any; c: unknown };
|
|
25
|
-
* expect<KeysOfExactType<C, never>>().
|
|
26
|
-
* expect<KeysOfExactType<C, any>>().
|
|
27
|
-
* expect<KeysOfExactType<C, unknown>>().
|
|
25
|
+
* expect<KeysOfExactType<C, never>>().to.be<'a'>().pass
|
|
26
|
+
* expect<KeysOfExactType<C, any>>().to.be<'b'>().pass
|
|
27
|
+
* expect<KeysOfExactType<C, unknown>>().to.be<'c'>().pass
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
export type KeysOfExactType<Obj, ValueType> = Exclude<{
|
|
@@ -45,17 +45,17 @@ export type KeysOfExactType<Obj, ValueType> = Exclude<{
|
|
|
45
45
|
*
|
|
46
46
|
* // Basic usage: match base type (non-optional property)
|
|
47
47
|
* type A = { a: 1; b: 2; c: 1 };
|
|
48
|
-
* expect<KeysOfBaseType<A, 1>>().
|
|
48
|
+
* expect<KeysOfBaseType<A, 1>>().to.be<'a' | 'c'>().pass
|
|
49
49
|
*
|
|
50
50
|
* // Key difference: optional property matching (ignores undefined)
|
|
51
51
|
* type B = { a?: string; b: string };
|
|
52
|
-
* expect<KeysOfBaseType<B, string>>().
|
|
53
|
-
* expect<KeysOfBaseType<B, string | undefined>>().
|
|
52
|
+
* expect<KeysOfBaseType<B, string>>().to.be<'a' | 'b'>().pass // matches base type of both
|
|
53
|
+
* expect<KeysOfBaseType<B, string | undefined>>().to.be<never>().pass // base type does not include undefined
|
|
54
54
|
*
|
|
55
55
|
* type C = { a: never; b: any; c: unknown };
|
|
56
|
-
* expect<KeysOfBaseType<C, never>>().
|
|
57
|
-
* expect<KeysOfBaseType<C, any>>().
|
|
58
|
-
* expect<KeysOfBaseType<C, unknown>>().
|
|
56
|
+
* expect<KeysOfBaseType<C, never>>().to.be<'a'>().pass
|
|
57
|
+
* expect<KeysOfBaseType<C, any>>().to.be<'b'>().pass
|
|
58
|
+
* expect<KeysOfBaseType<C, unknown>>().to.be<'c'>().pass
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
61
|
export type KeysOfBaseType<Obj, ValueType> = Exclude<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/utils/object/keys.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from '../index.js'\n\n/**\n * Extracts the keys of an object whose **complete value type** exactly matches the specified `ValueType` (including undefined for optional properties).\n *\n * This utility strictly matches the full type of each property (including `undefined` added by optional modifiers `?`).\n * For optional properties (e.g., `a?: string`), the type is treated as `string | undefined` – to match, `ValueType` must include `undefined`.\n *\n * @template Obj - The target object type to extract keys from.\n * @template ValueType - The exact type to match against property values (including undefined for optional properties).\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * // Basic usage: match exact type (non-optional property)\n * type A = { a: 1; b: 2; c: 1 };\n * expect<KeysOfExactType<A, 1>>().
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/utils/object/keys.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from '../index.js'\n\n/**\n * Extracts the keys of an object whose **complete value type** exactly matches the specified `ValueType` (including undefined for optional properties).\n *\n * This utility strictly matches the full type of each property (including `undefined` added by optional modifiers `?`).\n * For optional properties (e.g., `a?: string`), the type is treated as `string | undefined` – to match, `ValueType` must include `undefined`.\n *\n * @template Obj - The target object type to extract keys from.\n * @template ValueType - The exact type to match against property values (including undefined for optional properties).\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * // Basic usage: match exact type (non-optional property)\n * type A = { a: 1; b: 2; c: 1 };\n * expect<KeysOfExactType<A, 1>>().to.be<'a' | 'c'>().pass\n *\n * // Key difference: optional property matching (requires undefined in `ValueType`)\n * type B = { a?: string };\n * expect<KeysOfExactType<B, string | undefined>>().to.be<'a'>().pass // matches complete type\n * expect<KeysOfExactType<B, string>>().to.be<never>().pass // does not match complete type\n *\n * type C = { a: never; b: any; c: unknown };\n * expect<KeysOfExactType<C, never>>().to.be<'a'>().pass\n * expect<KeysOfExactType<C, any>>().to.be<'b'>().pass\n * expect<KeysOfExactType<C, unknown>>().to.be<'c'>().pass\n * ```\n */\nexport type KeysOfExactType<Obj, ValueType> = Exclude<\n { [K in keyof Obj]: Exact<Obj[K], ValueType> extends true ? K : never }[keyof Obj],\n undefined\n>\n\n/**\n * Extracts the keys of an object whose **base value type** matches the specified `ValueType` (ignoring undefined from optional properties).\n *\n * This utility matches the underlying/base type of each property (stripping `undefined` added by optional modifiers `?`).\n * For optional properties (e.g., `a?: string`), the type is treated as `string` – no need to include `undefined` in `ValueType` to match.\n *\n * @template Obj - The target object type to extract keys from.\n * @template ValueType - The base type to match against property values (ignoring undefined from optional properties).\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * // Basic usage: match base type (non-optional property)\n * type A = { a: 1; b: 2; c: 1 };\n * expect<KeysOfBaseType<A, 1>>().to.be<'a' | 'c'>().pass\n *\n * // Key difference: optional property matching (ignores undefined)\n * type B = { a?: string; b: string };\n * expect<KeysOfBaseType<B, string>>().to.be<'a' | 'b'>().pass // matches base type of both\n * expect<KeysOfBaseType<B, string | undefined>>().to.be<never>().pass // base type does not include undefined\n *\n * type C = { a: never; b: any; c: unknown };\n * expect<KeysOfBaseType<C, never>>().to.be<'a'>().pass\n * expect<KeysOfBaseType<C, any>>().to.be<'b'>().pass\n * expect<KeysOfBaseType<C, unknown>>().to.be<'c'>().pass\n * ```\n */\nexport type KeysOfBaseType<Obj, ValueType> = Exclude<\n {\n [K in keyof Obj]: Exact<Required<Obj>[K], ValueType> extends true ? K : never\n }[keyof Obj],\n undefined\n>\n"]}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* import { expect } from '@leawind/lay-sing'
|
|
10
10
|
*
|
|
11
11
|
* type Result = SafePick<{ a: string; b: number }, 'a' | 'c'>
|
|
12
|
-
* expect<Result>().
|
|
12
|
+
* expect<Result>().to.be<{ a: string }>().pass
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
export type SafePick<Obj, Key> = Pick<Obj, Key & keyof Obj>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../../src/utils/object/pick.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Safely picks keys `Key` from type `Obj`, excluding non-existent keys\n *\n * @template Obj - The object type to pick keys from\n * @template Key - The keys to pick from the object\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * type Result = SafePick<{ a: string; b: number }, 'a' | 'c'>\n * expect<Result>().
|
|
1
|
+
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../../src/utils/object/pick.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Safely picks keys `Key` from type `Obj`, excluding non-existent keys\n *\n * @template Obj - The object type to pick keys from\n * @template Key - The keys to pick from the object\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * type Result = SafePick<{ a: string; b: number }, 'a' | 'c'>\n * expect<Result>().to.be<{ a: string }>().pass\n * ```\n */\nexport type SafePick<Obj, Key> = Pick<Obj, Key & keyof Obj>\n"]}
|
|
@@ -10,7 +10,7 @@ import type { KeysOfBaseType } from '../index.js';
|
|
|
10
10
|
* import { expect } from '@leawind/lay-sing'
|
|
11
11
|
* type A = { a: string; b: number; c: string }
|
|
12
12
|
* type Strings = PropsOfBaseType<A, string> // { a: string; c: string }
|
|
13
|
-
* expect<PropsOfBaseType<A, string>>().
|
|
13
|
+
* expect<PropsOfBaseType<A, string>>().to.be<{ a: string; c: string }>()
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
export type PropsOfBaseType<T, U> = Pick<T, KeysOfBaseType<Required<T>, U>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utils/object/props.ts"],"names":[],"mappings":"","sourcesContent":["import type { KeysOfBaseType } from '../index.js'\n\n/**\n * Picks properties from `T` that have values of type `U`\n *\n * @template T - The object type to pick properties from\n * @template U - The value type to match against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n * type A = { a: string; b: number; c: string }\n * type Strings = PropsOfBaseType<A, string> // { a: string; c: string }\n * expect<PropsOfBaseType<A, string>>().
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utils/object/props.ts"],"names":[],"mappings":"","sourcesContent":["import type { KeysOfBaseType } from '../index.js'\n\n/**\n * Picks properties from `T` that have values of type `U`\n *\n * @template T - The object type to pick properties from\n * @template U - The value type to match against\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n * type A = { a: string; b: number; c: string }\n * type Strings = PropsOfBaseType<A, string> // { a: string; c: string }\n * expect<PropsOfBaseType<A, string>>().to.be<{ a: string; c: string }>()\n * ```\n */\nexport type PropsOfBaseType<T, U> = Pick<T, KeysOfBaseType<Required<T>, U>>\n"]}
|
|
@@ -9,8 +9,8 @@ import type { IfTupleIncludes } from '../index.js';
|
|
|
9
9
|
* ```ts
|
|
10
10
|
* import { expect } from '@leawind/lay-sing'
|
|
11
11
|
*
|
|
12
|
-
* expect<AppendUnique<[1, 2, 3], 4>>().
|
|
13
|
-
* expect<AppendUnique<[1, 2, 3], 2>>().
|
|
12
|
+
* expect<AppendUnique<[1, 2, 3], 4>>().to.be<[1, 2, 3, 4]>().pass
|
|
13
|
+
* expect<AppendUnique<[1, 2, 3], 2>>().to.be<[1, 2, 3]>().pass
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
export type AppendUnique<Tuple extends readonly unknown[], Element> = IfTupleIncludes<Tuple, Element> extends true ? Tuple : [...Tuple, Element];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append.js","sourceRoot":"","sources":["../../../src/utils/tuple/append.ts"],"names":[],"mappings":"","sourcesContent":["import type { IfTupleIncludes } from '../index.js'\n\n/**\n * Appends an element to a tuple only if it doesn't already exist in the tuple\n *\n * @template Tuple - The tuple type to append to\n * @template Element - The element type to append\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<AppendUnique<[1, 2, 3], 4>>().
|
|
1
|
+
{"version":3,"file":"append.js","sourceRoot":"","sources":["../../../src/utils/tuple/append.ts"],"names":[],"mappings":"","sourcesContent":["import type { IfTupleIncludes } from '../index.js'\n\n/**\n * Appends an element to a tuple only if it doesn't already exist in the tuple\n *\n * @template Tuple - The tuple type to append to\n * @template Element - The element type to append\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<AppendUnique<[1, 2, 3], 4>>().to.be<[1, 2, 3, 4]>().pass\n * expect<AppendUnique<[1, 2, 3], 2>>().to.be<[1, 2, 3]>().pass\n * ```\n */\nexport type AppendUnique<\n Tuple extends readonly unknown[],\n Element,\n> = IfTupleIncludes<Tuple, Element> extends true ? Tuple : [...Tuple, Element]\n"]}
|
|
@@ -9,7 +9,7 @@ import type { AppendUnique } from '../index.js';
|
|
|
9
9
|
* ```ts
|
|
10
10
|
* import { expect } from '@leawind/lay-sing'
|
|
11
11
|
*
|
|
12
|
-
* expect<ConcatTuple<[1, 2], [3, 4]>>().
|
|
12
|
+
* expect<ConcatTuple<[1, 2], [3, 4]>>().to.be<[1, 2, 3, 4]>().pass
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
export type ConcatTuple<Left extends readonly unknown[], Right extends readonly unknown[]> = Left extends readonly unknown[] ? (Right extends readonly unknown[] ? [...Left, ...Right] : never) : never;
|
|
@@ -24,7 +24,7 @@ export type ConcatTuple<Left extends readonly unknown[], Right extends readonly
|
|
|
24
24
|
* ```ts
|
|
25
25
|
* import { expect } from '@leawind/lay-sing'
|
|
26
26
|
*
|
|
27
|
-
* expect<ConcatUniqueTuple<[1, 2, 3], [2, 3, 4]>>().
|
|
27
|
+
* expect<ConcatUniqueTuple<[1, 2, 3], [2, 3, 4]>>().to.be<[1, 2, 3, 4]>().pass
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
export type ConcatUniqueTuple<Left extends readonly unknown[], Right extends readonly unknown[], R extends readonly unknown[] = Left> = Right extends readonly [infer First, ...infer Rest] ? ConcatUniqueTuple<Left, Rest, AppendUnique<R, First>> : R;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/utils/tuple/concat.ts"],"names":[],"mappings":"","sourcesContent":["// Import needed for ConcatUniqueTuple\nimport type { AppendUnique } from '../index.js'\n\n/**\n * Concatenates two tuples into a single tuple type\n *\n * @template Left - The first tuple type to concatenate\n * @template Right - The second tuple type to concatenate\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<ConcatTuple<[1, 2], [3, 4]>>().
|
|
1
|
+
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/utils/tuple/concat.ts"],"names":[],"mappings":"","sourcesContent":["// Import needed for ConcatUniqueTuple\nimport type { AppendUnique } from '../index.js'\n\n/**\n * Concatenates two tuples into a single tuple type\n *\n * @template Left - The first tuple type to concatenate\n * @template Right - The second tuple type to concatenate\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<ConcatTuple<[1, 2], [3, 4]>>().to.be<[1, 2, 3, 4]>().pass\n * ```\n */\nexport type ConcatTuple<\n Left extends readonly unknown[],\n Right extends readonly unknown[],\n> = Left extends readonly unknown[] ? (Right extends readonly unknown[] ? [...Left, ...Right] : never) : never\n\n/**\n * Concatenates two tuples while ensuring uniqueness of elements\n *\n * @template Left - The first tuple type to concatenate\n * @template Right - The second tuple type to concatenate\n * @template R - The intermediate result tuple type (defaults to `Left`)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<ConcatUniqueTuple<[1, 2, 3], [2, 3, 4]>>().to.be<[1, 2, 3, 4]>().pass\n * ```\n */\nexport type ConcatUniqueTuple<\n Left extends readonly unknown[],\n Right extends readonly unknown[],\n R extends readonly unknown[] = Left,\n> = Right extends readonly [infer First, ...infer Rest] ? ConcatUniqueTuple<Left, Rest, AppendUnique<R, First>> : R\n"]}
|
|
@@ -11,9 +11,9 @@ import type { Exact } from '../index.js';
|
|
|
11
11
|
* ```ts
|
|
12
12
|
* import { expect } from '@leawind/lay-sing'
|
|
13
13
|
*
|
|
14
|
-
* expect<IfTupleIncludes<[1, 2, 3], 2>>().
|
|
15
|
-
* expect<IfTupleIncludes<[1, 2, 3], 4>>().
|
|
16
|
-
* expect<IfTupleIncludes<[1, 2, 1], 1>>().
|
|
14
|
+
* expect<IfTupleIncludes<[1, 2, 3], 2>>().to.be.true
|
|
15
|
+
* expect<IfTupleIncludes<[1, 2, 3], 4>>().to.be.false
|
|
16
|
+
* expect<IfTupleIncludes<[1, 2, 1], 1>>().to.be.true
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export type IfTupleIncludes<Tuple extends readonly unknown[], Element, Yes = true, No = false> = Exact<Tuple, any> extends true ? never : Tuple extends readonly [infer First, ...infer Rest] ? (Exact<Element, First> extends true ? Yes : IfTupleIncludes<Rest, Element, Yes, No>) : No;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"includes.js","sourceRoot":"","sources":["../../../src/utils/tuple/includes.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from '../index.js'\n\n/**\n * Checks whether a tuple includes a specific element type\n *\n * @template Tuple - The tuple type to check\n * @template Element - The element type to look for\n * @template Yes - The result if the element is found (defaults to `true`)\n * @template No - The result if the element is not found (defaults to `false`)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<IfTupleIncludes<[1, 2, 3], 2>>().
|
|
1
|
+
{"version":3,"file":"includes.js","sourceRoot":"","sources":["../../../src/utils/tuple/includes.ts"],"names":[],"mappings":"","sourcesContent":["import type { Exact } from '../index.js'\n\n/**\n * Checks whether a tuple includes a specific element type\n *\n * @template Tuple - The tuple type to check\n * @template Element - The element type to look for\n * @template Yes - The result if the element is found (defaults to `true`)\n * @template No - The result if the element is not found (defaults to `false`)\n *\n * @example\n * ```ts\n * import { expect } from '@leawind/lay-sing'\n *\n * expect<IfTupleIncludes<[1, 2, 3], 2>>().to.be.true\n * expect<IfTupleIncludes<[1, 2, 3], 4>>().to.be.false\n * expect<IfTupleIncludes<[1, 2, 1], 1>>().to.be.true\n * ```\n */\nexport type IfTupleIncludes<\n Tuple extends readonly unknown[],\n Element,\n Yes = true,\n No = false,\n> = Exact<Tuple, any> extends true ? never\n : Tuple extends readonly [infer First, ...infer Rest]\n ? (Exact<Element, First> extends true ? Yes : IfTupleIncludes<Rest, Element, Yes, No>)\n : No\n"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { To } from './to/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the result of a type assertion based on a boolean condition.
|
|
4
|
+
*
|
|
5
|
+
* - If `true`, the result has a `pass` property;
|
|
6
|
+
* - If `false`, the result has a `fail` property;
|
|
7
|
+
* - Otherwise, the result is `never`
|
|
8
|
+
*
|
|
9
|
+
* @template B The boolean condition result (true or false)
|
|
10
|
+
* @template R The type of the result value (default is void)
|
|
11
|
+
*/
|
|
12
|
+
export type TypeAssertionResult<T, B extends boolean, R = ExpectType<T>> = [B] extends [true] ? {
|
|
13
|
+
/**
|
|
14
|
+
* This field exist only when this type assertion succeed
|
|
15
|
+
*
|
|
16
|
+
* If you expect this assertion to fail, use `.fail`
|
|
17
|
+
*/
|
|
18
|
+
pass: R;
|
|
19
|
+
} : [B] extends [false] ? {
|
|
20
|
+
/**
|
|
21
|
+
* This field exist only when this type assertion failed
|
|
22
|
+
*
|
|
23
|
+
* If you expect this assertion to pass, use `.pass`
|
|
24
|
+
*/
|
|
25
|
+
fail: R;
|
|
26
|
+
} : never;
|
|
27
|
+
export type ExpectType<T> = {
|
|
28
|
+
to: To<T>;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Exact, If, Xor } from '../../../utils/index.js';
|
|
2
|
+
import type { TypeAssertionResult } from '../index.js';
|
|
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
|
+
any: void;
|
|
8
|
+
}, {}> & If<Xor<Inv, Exact<T, never>>, {
|
|
9
|
+
never: void;
|
|
10
|
+
}, {}> & If<Xor<Inv, Exact<T, unknown>>, {
|
|
11
|
+
unknown: void;
|
|
12
|
+
}, {}> & If<Xor<Inv, Exact<T, void>>, {
|
|
13
|
+
void: void;
|
|
14
|
+
}, {}> & If<Xor<Inv, Exact<T, null>>, {
|
|
15
|
+
null: void;
|
|
16
|
+
}, {}> & If<Xor<Inv, Exact<T, undefined>>, {
|
|
17
|
+
undefined: void;
|
|
18
|
+
}, {}> & If<Xor<Inv, Exact<T, true>>, {
|
|
19
|
+
true: void;
|
|
20
|
+
}, {}> & If<Xor<Inv, Exact<T, false>>, {
|
|
21
|
+
false: void;
|
|
22
|
+
}, {}>;
|
|
23
|
+
//# sourceMappingURL=be.d.ts.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MutuallyAssignable, Xor } from '../../../utils/index.js';
|
|
2
|
+
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
+
export type Equal<T, Inv extends boolean = false> = {
|
|
4
|
+
/**
|
|
5
|
+
* Tests if the current type is mutually assignable with the provided type U.
|
|
6
|
+
*
|
|
7
|
+
* It's like:
|
|
8
|
+
*
|
|
9
|
+
* ```ts ignore
|
|
10
|
+
* [T] extends [U] ? [U] extends [T] ? Yes : No : No
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @template U The type to compare with
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { expect } from '@leawind/lay-sing'
|
|
18
|
+
*
|
|
19
|
+
* expect<{ a: 1; b: 2 }>().to.equal<{ a: 1 } & { b: 2 }>().pass
|
|
20
|
+
* expect<1>().to.equal<1 | 2>().fail
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>;
|
|
24
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, MutuallyAssignable<T, U>>>;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=equal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Extends, If, Xor } from '../../../utils/index.js';
|
|
2
|
+
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
+
export type Extend<T, Inv extends boolean = false> = {
|
|
4
|
+
/**
|
|
5
|
+
* Tests if the current type T extends the provided type U.
|
|
6
|
+
*
|
|
7
|
+
* @template U The type to check extension against
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { expect } from '@leawind/lay-sing'
|
|
12
|
+
*
|
|
13
|
+
* expect<3.14>().to.extend<number>().pass
|
|
14
|
+
* expect<2>().to.extend<string>().fail
|
|
15
|
+
* expect<'hello'>().to.extend<string>().pass
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
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
|
+
number: void;
|
|
22
|
+
}, {}> & If<Xor<Inv, Extends<T, bigint>>, {
|
|
23
|
+
bigint: void;
|
|
24
|
+
}, {}> & If<Xor<Inv, Extends<T, string>>, {
|
|
25
|
+
string: void;
|
|
26
|
+
}, {}> & If<Xor<Inv, Extends<T, boolean>>, {
|
|
27
|
+
boolean: void;
|
|
28
|
+
}, {}> & If<Xor<Inv, Extends<T, symbol>>, {
|
|
29
|
+
symbol: void;
|
|
30
|
+
}, {}>;
|
|
31
|
+
//# sourceMappingURL=extend.d.ts.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Extends, IfTupleIncludes, Xor } from '../../../utils/index.js';
|
|
2
|
+
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
+
type Result<T, K extends PropertyKey, Inv extends boolean = false> = IfTupleIncludes<[
|
|
4
|
+
never,
|
|
5
|
+
any
|
|
6
|
+
], K, never, TypeAssertionResult<T, Xor<Inv, Extends<K, keyof T>>>>;
|
|
7
|
+
export type HaveKey<T, Inv extends boolean = false> = {
|
|
8
|
+
/**
|
|
9
|
+
* Tests if the current type `T` has a property with key `K`.
|
|
10
|
+
*
|
|
11
|
+
* @template K The property key to check for
|
|
12
|
+
*
|
|
13
|
+
* ### Behavior
|
|
14
|
+
*
|
|
15
|
+
* - For single keys: succeeds if the key exists in `T`
|
|
16
|
+
* - For union types: succeeds only if **all** keys in the union exist in `T`
|
|
17
|
+
*
|
|
18
|
+
* ### Examples
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { expect } from '@leawind/lay-sing'
|
|
22
|
+
*
|
|
23
|
+
* type WithProp = { prop: string; another: number; may?: 5 }
|
|
24
|
+
*
|
|
25
|
+
* // Single key checks
|
|
26
|
+
* expect<WithProp>().to.haveKey<'prop'>().pass
|
|
27
|
+
* expect<WithProp>().to.haveKey<'missing'>().fail
|
|
28
|
+
*
|
|
29
|
+
* // Union type checks
|
|
30
|
+
* expect<WithProp>().to.haveKey<'prop' | 'another'>().pass
|
|
31
|
+
* expect<WithProp>().to.haveKey<'may' | 'unexist'>().fail
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
<K extends PropertyKey>(): Result<T, K, Inv>;
|
|
35
|
+
<K extends PropertyKey>(_: K): Result<T, K, Inv>;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=have-key.d.ts.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Not } from '../../../utils/logic/boolean.js';
|
|
2
|
+
import type { Be } from './be.js';
|
|
3
|
+
import type { Equal } from './equal.js';
|
|
4
|
+
import type { Extend } from './extend.js';
|
|
5
|
+
import type { ProperExtends } from './proper-extends.js';
|
|
6
|
+
import type { HaveKey } from './have-key.js';
|
|
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>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ProperExtend, Xor } from '../../../utils/index.js';
|
|
2
|
+
import type { TypeAssertionResult } from '../index.js';
|
|
3
|
+
export type ProperExtends<T, Inv extends boolean = false> = {
|
|
4
|
+
/**
|
|
5
|
+
* Tests if the current type T properly extends the provided type U (extends but is not the same).
|
|
6
|
+
*
|
|
7
|
+
* @template U The type to check proper extension against
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { expect } from '@leawind/lay-sing'
|
|
12
|
+
*
|
|
13
|
+
* expect<2>().to.properExtend<number>().pass
|
|
14
|
+
* expect<'a' | 'b'>().to.properExtend<string>().pass
|
|
15
|
+
* expect<number>().to.properExtend<number>().fail
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
<U>(): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>;
|
|
19
|
+
<U>(_: U): TypeAssertionResult<T, Xor<Inv, ProperExtend<T, U>>>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=proper-extends.d.ts.map
|
|
@@ -0,0 +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,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"}
|