lay-sing 0.1.0

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.
Files changed (125) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -0
  3. package/esm/main/array.d.ts +48 -0
  4. package/esm/main/array.d.ts.map +1 -0
  5. package/esm/main/array.js +2 -0
  6. package/esm/main/array.js.map +1 -0
  7. package/esm/main/async.d.ts +5 -0
  8. package/esm/main/async.d.ts.map +1 -0
  9. package/esm/main/async.js +2 -0
  10. package/esm/main/async.js.map +1 -0
  11. package/esm/main/boolean.d.ts +36 -0
  12. package/esm/main/boolean.d.ts.map +1 -0
  13. package/esm/main/boolean.js +2 -0
  14. package/esm/main/boolean.js.map +1 -0
  15. package/esm/main/control.d.ts +88 -0
  16. package/esm/main/control.d.ts.map +1 -0
  17. package/esm/main/control.js +2 -0
  18. package/esm/main/control.js.map +1 -0
  19. package/esm/main/doc.d.ts +30 -0
  20. package/esm/main/doc.d.ts.map +1 -0
  21. package/esm/main/doc.js +2 -0
  22. package/esm/main/doc.js.map +1 -0
  23. package/esm/main/function.d.ts +21 -0
  24. package/esm/main/function.d.ts.map +1 -0
  25. package/esm/main/function.js +3 -0
  26. package/esm/main/function.js.map +1 -0
  27. package/esm/main/index.d.ts +12 -0
  28. package/esm/main/index.d.ts.map +1 -0
  29. package/esm/main/index.js +12 -0
  30. package/esm/main/index.js.map +1 -0
  31. package/esm/main/json.d.ts +44 -0
  32. package/esm/main/json.d.ts.map +1 -0
  33. package/esm/main/json.js +2 -0
  34. package/esm/main/json.js.map +1 -0
  35. package/esm/main/key.d.ts +26 -0
  36. package/esm/main/key.d.ts.map +1 -0
  37. package/esm/main/key.js +2 -0
  38. package/esm/main/key.js.map +1 -0
  39. package/esm/main/object.d.ts +81 -0
  40. package/esm/main/object.d.ts.map +1 -0
  41. package/esm/main/object.js +2 -0
  42. package/esm/main/object.js.map +1 -0
  43. package/esm/main/type/compare.d.ts +79 -0
  44. package/esm/main/type/compare.d.ts.map +1 -0
  45. package/esm/main/type/compare.js +2 -0
  46. package/esm/main/type/compare.js.map +1 -0
  47. package/esm/main/type/index.d.ts +3 -0
  48. package/esm/main/type/index.d.ts.map +1 -0
  49. package/esm/main/type/index.js +3 -0
  50. package/esm/main/type/index.js.map +1 -0
  51. package/esm/main/type/set.d.ts +29 -0
  52. package/esm/main/type/set.d.ts.map +1 -0
  53. package/esm/main/type/set.js +2 -0
  54. package/esm/main/type/set.js.map +1 -0
  55. package/esm/main/typed-array.d.ts +5 -0
  56. package/esm/main/typed-array.d.ts.map +1 -0
  57. package/esm/main/typed-array.js +2 -0
  58. package/esm/main/typed-array.js.map +1 -0
  59. package/esm/package.json +3 -0
  60. package/esm/test-utils.d.ts +348 -0
  61. package/esm/test-utils.d.ts.map +1 -0
  62. package/esm/test-utils.js +49 -0
  63. package/esm/test-utils.js.map +1 -0
  64. package/package.json +29 -0
  65. package/script/main/array.d.ts +48 -0
  66. package/script/main/array.d.ts.map +1 -0
  67. package/script/main/array.js +3 -0
  68. package/script/main/array.js.map +1 -0
  69. package/script/main/async.d.ts +5 -0
  70. package/script/main/async.d.ts.map +1 -0
  71. package/script/main/async.js +3 -0
  72. package/script/main/async.js.map +1 -0
  73. package/script/main/boolean.d.ts +36 -0
  74. package/script/main/boolean.d.ts.map +1 -0
  75. package/script/main/boolean.js +3 -0
  76. package/script/main/boolean.js.map +1 -0
  77. package/script/main/control.d.ts +88 -0
  78. package/script/main/control.d.ts.map +1 -0
  79. package/script/main/control.js +3 -0
  80. package/script/main/control.js.map +1 -0
  81. package/script/main/doc.d.ts +30 -0
  82. package/script/main/doc.d.ts.map +1 -0
  83. package/script/main/doc.js +3 -0
  84. package/script/main/doc.js.map +1 -0
  85. package/script/main/function.d.ts +21 -0
  86. package/script/main/function.d.ts.map +1 -0
  87. package/script/main/function.js +4 -0
  88. package/script/main/function.js.map +1 -0
  89. package/script/main/index.d.ts +12 -0
  90. package/script/main/index.d.ts.map +1 -0
  91. package/script/main/index.js +28 -0
  92. package/script/main/index.js.map +1 -0
  93. package/script/main/json.d.ts +44 -0
  94. package/script/main/json.d.ts.map +1 -0
  95. package/script/main/json.js +3 -0
  96. package/script/main/json.js.map +1 -0
  97. package/script/main/key.d.ts +26 -0
  98. package/script/main/key.d.ts.map +1 -0
  99. package/script/main/key.js +3 -0
  100. package/script/main/key.js.map +1 -0
  101. package/script/main/object.d.ts +81 -0
  102. package/script/main/object.d.ts.map +1 -0
  103. package/script/main/object.js +3 -0
  104. package/script/main/object.js.map +1 -0
  105. package/script/main/type/compare.d.ts +79 -0
  106. package/script/main/type/compare.d.ts.map +1 -0
  107. package/script/main/type/compare.js +3 -0
  108. package/script/main/type/compare.js.map +1 -0
  109. package/script/main/type/index.d.ts +3 -0
  110. package/script/main/type/index.d.ts.map +1 -0
  111. package/script/main/type/index.js +19 -0
  112. package/script/main/type/index.js.map +1 -0
  113. package/script/main/type/set.d.ts +29 -0
  114. package/script/main/type/set.d.ts.map +1 -0
  115. package/script/main/type/set.js +3 -0
  116. package/script/main/type/set.js.map +1 -0
  117. package/script/main/typed-array.d.ts +5 -0
  118. package/script/main/typed-array.d.ts.map +1 -0
  119. package/script/main/typed-array.js +3 -0
  120. package/script/main/typed-array.js.map +1 -0
  121. package/script/package.json +3 -0
  122. package/script/test-utils.d.ts +348 -0
  123. package/script/test-utils.d.ts.map +1 -0
  124. package/script/test-utils.js +54 -0
  125. package/script/test-utils.js.map +1 -0
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NOOP = void 0;
4
+ exports.expect = expect;
5
+ exports.compare = compare;
6
+ /**
7
+ * A universal no-op placeholder implemented via `Proxy`.
8
+ *
9
+ * `NOOP` can be accessed, called, or chained indefinitely without throwing.
10
+ * Every operation returns itself, making it safe to use as a dummy fallback
11
+ * for APIs, optional hooks, or unimplemented interfaces.
12
+ *
13
+ * ### Special behaviors
14
+ *
15
+ * - Callable: invoking `NOOP()` returns `NOOP`
16
+ * - Property access: `NOOP.anything` returns `NOOP`
17
+ * - Promise-safe: `NOOP.then` is `undefined`, so it is not treated as a Promise
18
+ * - Primitive coercion (`toString`, `valueOf`, `Symbol.toPrimitive`) yields
19
+ * a stable string representation: `"[NOOP]"`
20
+ *
21
+ * This is useful in scenarios where a value is required syntactically but
22
+ * should perform no action and never fail at runtime.
23
+ *
24
+ * ### Examples
25
+ *
26
+ * ```ts
27
+ * NOOP.foo.bar().baz.qux; // safe, returns NOOP
28
+ * String(NOOP); // "[NOOP]"
29
+ * await NOOP; // does not await (not thenable)
30
+ * ```
31
+ */
32
+ exports.NOOP = new Proxy(function () {
33
+ return exports.NOOP;
34
+ }, {
35
+ get(_, prop) {
36
+ switch (prop) {
37
+ case 'then':
38
+ return undefined;
39
+ case 'valueOf':
40
+ case 'toString':
41
+ case Symbol.toPrimitive:
42
+ return () => '[NOOP]';
43
+ default:
44
+ return exports.NOOP;
45
+ }
46
+ },
47
+ });
48
+ function expect() {
49
+ return exports.NOOP;
50
+ }
51
+ function compare() {
52
+ return exports.NOOP;
53
+ }
54
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":";;;AA2TA,wBAEC;AA+GD,0BAEC;AAjaD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACU,QAAA,IAAI,GAAQ,IAAI,KAAK,CAChC;IACE,OAAO,YAAI,CAAA;AACb,CAAC,EACD;IACE,GAAG,CAAC,CAAC,EAAE,IAAI;QACT,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACT,OAAO,SAAS,CAAA;YAClB,KAAK,SAAS,CAAC;YACf,KAAK,UAAU,CAAC;YAChB,KAAK,MAAM,CAAC,WAAW;gBACrB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAA;YACvB;gBACE,OAAO,YAAI,CAAA;QACf,CAAC;IACH,CAAC;CACF,CACF,CAAA;AAkQD,SAAgB,MAAM;IACpB,OAAO,YAAI,CAAA;AACb,CAAC;AA+GD,SAAgB,OAAO;IACrB,OAAO,YAAI,CAAA;AACb,CAAC","sourcesContent":["// deno-lint-ignore-file no-explicit-any\nimport type {\n Diff,\n Disjoint,\n Extends,\n If,\n MutuallyAssignable,\n Overlap,\n ProperExtend,\n SafePick,\n Same,\n} from './main/index.js'\n\n/**\n * A universal no-op placeholder implemented via `Proxy`.\n *\n * `NOOP` can be accessed, called, or chained indefinitely without throwing.\n * Every operation returns itself, making it safe to use as a dummy fallback\n * for APIs, optional hooks, or unimplemented interfaces.\n *\n * ### Special behaviors\n *\n * - Callable: invoking `NOOP()` returns `NOOP`\n * - Property access: `NOOP.anything` returns `NOOP`\n * - Promise-safe: `NOOP.then` is `undefined`, so it is not treated as a Promise\n * - Primitive coercion (`toString`, `valueOf`, `Symbol.toPrimitive`) yields\n * a stable string representation: `\"[NOOP]\"`\n *\n * This is useful in scenarios where a value is required syntactically but\n * should perform no action and never fail at runtime.\n *\n * ### Examples\n *\n * ```ts\n * NOOP.foo.bar().baz.qux; // safe, returns NOOP\n * String(NOOP); // \"[NOOP]\"\n * await NOOP; // does not await (not thenable)\n * ```\n */\nexport const NOOP: any = new Proxy(\n function () {\n return NOOP\n },\n {\n get(_, prop) {\n switch (prop) {\n case 'then':\n return undefined\n case 'valueOf':\n case 'toString':\n case Symbol.toPrimitive:\n return () => '[NOOP]'\n default:\n return NOOP\n }\n },\n },\n)\n\n/**\n * Represents the result of a type assertion based on a boolean condition.\n * If the condition is true, the result has a `success` property; otherwise, it has a `fail` property.\n *\n * @template B The boolean condition result (true or false)\n * @template R The type of the result value (default is void)\n */\ntype Result<B extends true | false, R = void> = B extends true ? {\n /**\n * ## Expect to succeed without type error\n */\n success: R\n }\n : {\n /**\n * ## Expect to fail with type error\n */\n fail: R\n }\n\n/**\n * Type-level testing utility that allows checking various relationships between types.\n * Provides methods to test type equality, extension, properties, and more.\n *\n * @template T The type being tested\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * ### Examples\n *\n * ```ts\n * // Test if two types are identical\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<2>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * // Test if type has a specific property\n * expect<{name: string}>().toHaveProperty<'name'>().success\n * ```\n */\nexport type ExpectType<T, H extends PropertyKey = never> = Omit<\n (\n & {\n T: T\n inspect: { [K in keyof T]: T[K] }\n\n /**\n * Tests if the current type is exactly the same as the provided type U.\n *\n * @template U The type to compare with\n *\n * ### Examples\n *\n * ```ts\n * expect<any>().toBe<any>().success\n * expect<never>().toBe<never>().success\n * expect<false>().toBe<true>().fail\n * ```\n */\n toBe<U>(): Result<Same<T, U>>\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 * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * expect<'hello'>().toExtend<string>().success\n * ```\n */\n toExtend<U>(): Result<Extends<T, U>>\n\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 * ### Examples\n *\n * ```ts\n * expect<2>().toProperExtend<number>().success\n * expect<'a' | 'b'>().toProperExtend<string>().success\n * expect<number>().toProperExtend<number>().fail\n * ```\n */\n toProperExtend<U>(): Result<ProperExtend<T, U>>\n\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 * ### Examples\n *\n * ```ts\n * type WithProp = { prop: string; another: number }\n * expect<WithProp>().toHaveProperty<'prop'>().success\n * expect<WithProp>().toHaveProperty<'another'>().success\n * expect<WithProp>().toHaveProperty<'missing'>().fail\n * ```\n */\n toHaveProperty<K extends PropertyKey>(): Result<Extends<K, keyof T>>\n }\n & SafePick<\n {\n /**\n * Tests if the current type extends the Number primitive type.\n * Available only if the current type extends number.\n *\n * ### Examples\n *\n * ```ts\n * expect<3.14>().toExtendNumber // Available and would succeed\n * ```\n */\n toExtendNumber: ExpectType<T, H | 'toExtendNumber' | 'toExtend'>\n\n /**\n * Tests if the current type extends the String primitive type.\n * Available only if the current type extends string.\n *\n * ### Examples\n *\n * ```ts\n * expect<'hello'>().toExtendString // Available and would succeed\n * ```\n */\n toExtendString: ExpectType<T, H | 'toExtendString' | 'toExtend'>\n\n /**\n * Tests if the current type extends the Boolean primitive type.\n * Available only if the current type extends boolean.\n *\n * ### Examples\n *\n * ```ts\n * expect<true>().toExtendBoolean // Available and would succeed\n * ```\n */\n toExtendBoolean: ExpectType<T, H | 'toExtendBoolean' | 'toExtend'>\n },\n | If<Extends<T, number>, 'toExtendNumber'>\n | If<Extends<T, string>, 'toExtendString'>\n | If<Extends<T, boolean>, 'toExtendBoolean'>\n >\n & SafePick<\n {\n /**\n * Tests if the current type is exactly `any`.\n * Available only if the current type is `any`.\n *\n * ### Examples\n *\n * ```ts\n * expect<any>().toBeAny // Available and would succeed\n * ```\n */\n toBeAny: ExpectType<T, H | 'toBeAny' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `never`.\n * Available only if the current type is `never`.\n *\n * ### Examples\n *\n * ```ts\n * expect<never>().toBeNever // Available and would succeed\n * ```\n */\n toBeNever: ExpectType<T, H | 'toBeNever' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `unknown`.\n * Available only if the current type is `unknown`.\n *\n * ### Examples\n *\n * ```ts\n * expect<unknown>().toBeUnknown // Available and would succeed\n * ```\n */\n toBeUnknown: ExpectType<T, H | 'toBeUnknown' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `void`.\n * Available only if the current type is `void`.\n *\n * ### Examples\n *\n * ```ts\n * expect<void>().toBeVoid // Available and would succeed\n * ```\n */\n toBeVoid: ExpectType<T, H | 'toBeVoid' | 'toBe'>\n\n /**\n * Tests if the current type is exactly `true` (boolean literal).\n * Available only if the current type is `true`.\n *\n * ### Examples\n *\n * ```ts\n * expect<true>().toBeTrue // Available and would succeed\n * ```\n */\n toBeTrue: ExpectType<T, H | 'toBeTrue' | 'toBe' | 'toExtendBoolean'>\n\n /**\n * Tests if the current type is exactly `false` (boolean literal).\n * Available only if the current type is `false`.\n *\n * ### Examples\n *\n * ```ts\n * expect<false>().toBeFalse // Available and would succeed\n * ```\n */\n toBeFalse: ExpectType<T, H | 'toBeFalse' | 'toBe' | 'toExtendBoolean'>\n },\n | If<Same<T, any>, 'toBeAny'>\n | If<Same<T, never>, 'toBeNever'>\n | If<Same<T, unknown>, 'toBeUnknown'>\n | If<Same<T, void>, 'toBeVoid'>\n | If<Same<T, true>, 'toBeTrue'>\n | If<Same<T, false>, 'toBeFalse'>\n >\n ),\n H\n>\n\n/**\n * Creates an instance of ExpectType to perform type-level assertions on the given type.\n * This function enables testing various type relationships at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T The type to be tested\n *\n * @returns An ExpectType instance with methods to test type relationships\n *\n * ### Examples\n *\n * ```ts\n * // Test exact type equality\n * expect<number>().toBe<number>().success\n * expect<number>().toBe<string>().fail\n * // Test if one type extends another\n * expect<3.14>().toExtend<number>().success\n * expect<2>().toExtend<string>().fail\n * ```\n */\nexport function expect<T>(): ExpectType<T>\nexport function expect<T>(_: T): ExpectType<T>\nexport function expect<T>(): ExpectType<T> {\n return NOOP\n}\n\n/**\n * Type-level utility that compares two types and provides methods to test their relationship.\n * Offers options to check if types are same, different, overlapping, disjoint, or mutually assignable.\n *\n * @template T First type to compare\n * @template U Second type to compare\n * @template H Hidden property keys that are already used (internal tracking)\n *\n * ### Examples\n *\n * ```ts\n * // Check if two types are the same\n * compare<number, number>().same // Available\n * // Check if two types are different\n * compare<number, string>().different // Available\n * // Check if two types overlap\n * compare<4, number>().overlap.different // Available\n * ```\n */\nexport type CompareTypes<T, U, H extends PropertyKey = never> = Omit<\n SafePick<\n {\n /**\n * Available when types T and U are exactly the same.\n *\n * ### Examples\n *\n * ```ts\n * compare<3, 3>().same // Available\n * compare<boolean, boolean>().same // Available\n * ```\n */\n same: CompareTypes<T, U, H | 'same'>\n\n /**\n * Available when types T and U are different.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different // Available\n * compare<number, 4>().different // Available\n * ```\n */\n different: CompareTypes<T, U, H | 'different'>\n\n /**\n * Available when types T and U have some overlap.\n *\n * ### Examples\n *\n * ```ts\n * compare<4, number>().overlap // Available since 4 overlaps with number\n * ```\n */\n overlap: CompareTypes<T, U, H | 'overlap'>\n\n /**\n * Available when types T and U have no overlap (are disjoint).\n *\n * ### Examples\n *\n * ```ts\n * compare<4, 'abc'>().different.disjoint // Available since 4 and 'abc' are disjoint\n * ```\n */\n disjoint: CompareTypes<T, U, H | 'disjoint'>\n\n /**\n * Available when types T and U are mutually assignable (each type can be assigned to the other).\n *\n * ### Examples\n *\n * ```ts\n * compare<1 | 2, 1 | 2>().mutuallyAssignable // Available since identical union types are mutually assignable\n * ```\n */\n mutuallyAssignable: CompareTypes<T, U, H | 'mutuallyAssignable'>\n },\n | If<Same<T, U>, 'same'>\n | If<Diff<T, U>, 'different'>\n | If<Overlap<T, U>, 'overlap'>\n | If<Disjoint<T, U>, 'disjoint'>\n | If<MutuallyAssignable<T, U>, 'mutuallyAssignable'>\n >,\n H\n>\n\n/**\n * Creates an instance of CompareTypes to perform type-level comparisons between two types.\n * This function enables testing various relationships between types at compile time.\n * NOTE: This function does nothing at runtime and is purely for type-level testing.\n *\n * @template T First type to compare\n * @template U Second type to compare\n *\n * @returns A CompareTypes instance with methods to test relationships between T and U\n *\n * ### Examples\n *\n * ```ts\n * // Compare two identical types\n * compare<number, number>().same // Results in an available property\n * // Compare two different but overlapping types\n * compare<4, number>().overlap.different // Results in available properties\n * ```\n */\nexport function compare<T, U>(): CompareTypes<T, U>\nexport function compare<T, U>(t: T, u: U): CompareTypes<T, U>\nexport function compare<T, U>(): CompareTypes<T, U> {\n return NOOP\n}\n"]}