@ls-stack/utils 3.14.0 → 3.15.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.
@@ -25,8 +25,10 @@ __export(typingFnUtils_exports, {
25
25
  isObjKey: () => isObjKey,
26
26
  isSubTypeOf: () => isSubTypeOf,
27
27
  narrowStringToUnion: () => narrowStringToUnion,
28
+ typeOnRightExtendsLeftType: () => typeOnRightExtendsLeftType,
28
29
  typedObjectEntries: () => typedObjectEntries,
29
- typedObjectKeys: () => typedObjectKeys
30
+ typedObjectKeys: () => typedObjectKeys,
31
+ unionsAreTheSame: () => unionsAreTheSame
30
32
  });
31
33
  module.exports = __toCommonJS(typingFnUtils_exports);
32
34
  function asNonPartial(obj) {
@@ -47,12 +49,15 @@ function narrowStringToUnion(key, union) {
47
49
  }
48
50
  return void 0;
49
51
  }
50
- function isSubTypeOf() {
52
+ function typeOnRightExtendsLeftType() {
51
53
  return void 0;
52
54
  }
55
+ var isSubTypeOf = typeOnRightExtendsLeftType;
53
56
  function isObjKey(key, obj) {
54
57
  return typeof key === "string" && key in obj;
55
58
  }
59
+ function unionsAreTheSame(_diff) {
60
+ }
56
61
  // Annotate the CommonJS export names for ESM import in node:
57
62
  0 && (module.exports = {
58
63
  asNonPartial,
@@ -60,6 +65,8 @@ function isObjKey(key, obj) {
60
65
  isObjKey,
61
66
  isSubTypeOf,
62
67
  narrowStringToUnion,
68
+ typeOnRightExtendsLeftType,
63
69
  typedObjectEntries,
64
- typedObjectKeys
70
+ typedObjectKeys,
71
+ unionsAreTheSame
65
72
  });
@@ -18,10 +18,33 @@ declare function narrowStringToUnion<const T extends string>(key: string | undef
18
18
  * @template SubType - The type that should extend BaseType
19
19
  * @returns {unknown} Returns undefined, only used for type checking
20
20
  */
21
- declare function isSubTypeOf<BaseType, SubType extends BaseType>(): unknown;
21
+ declare function typeOnRightExtendsLeftType<BaseType, SubType extends BaseType>(): unknown;
22
+ /** @deprecated use typeOnRightExtendsLeftType instead */
23
+ declare const isSubTypeOf: typeof typeOnRightExtendsLeftType;
22
24
  /**
23
25
  * Type helper to narrow a string to a key of an object.
24
26
  */
25
27
  declare function isObjKey<T extends Record<string, unknown>>(key: unknown, obj: T): key is keyof T;
28
+ type UnionDiff<T, U> = [
29
+ T
30
+ ] extends [U] ? [
31
+ U
32
+ ] extends [T] ? null : {
33
+ onRightHasExtra: Exclude<U, T>;
34
+ } : [U] extends [T] ? {
35
+ onRightHasMissing: Exclude<T, U>;
36
+ } : {
37
+ onRightHasExtra: Exclude<U, T>;
38
+ onRightHasMissing: Exclude<T, U>;
39
+ };
40
+ /**
41
+ * Type helper to compare two union types and determine their relationship.
42
+ *
43
+ * @template T - The first union type (left side)
44
+ * @template U - The second union type (right side)
45
+ * @param _diff - null if unions are identical, or an object describing the difference
46
+ * @returns void - This function is only used for type checking
47
+ */
48
+ declare function unionsAreTheSame<T, U>(_diff: UnionDiff<T, U>): void;
26
49
 
27
- export { asNonPartial, asType, isObjKey, isSubTypeOf, narrowStringToUnion, typedObjectEntries, typedObjectKeys };
50
+ export { asNonPartial, asType, isObjKey, isSubTypeOf, narrowStringToUnion, typeOnRightExtendsLeftType, typedObjectEntries, typedObjectKeys, unionsAreTheSame };
@@ -18,10 +18,33 @@ declare function narrowStringToUnion<const T extends string>(key: string | undef
18
18
  * @template SubType - The type that should extend BaseType
19
19
  * @returns {unknown} Returns undefined, only used for type checking
20
20
  */
21
- declare function isSubTypeOf<BaseType, SubType extends BaseType>(): unknown;
21
+ declare function typeOnRightExtendsLeftType<BaseType, SubType extends BaseType>(): unknown;
22
+ /** @deprecated use typeOnRightExtendsLeftType instead */
23
+ declare const isSubTypeOf: typeof typeOnRightExtendsLeftType;
22
24
  /**
23
25
  * Type helper to narrow a string to a key of an object.
24
26
  */
25
27
  declare function isObjKey<T extends Record<string, unknown>>(key: unknown, obj: T): key is keyof T;
28
+ type UnionDiff<T, U> = [
29
+ T
30
+ ] extends [U] ? [
31
+ U
32
+ ] extends [T] ? null : {
33
+ onRightHasExtra: Exclude<U, T>;
34
+ } : [U] extends [T] ? {
35
+ onRightHasMissing: Exclude<T, U>;
36
+ } : {
37
+ onRightHasExtra: Exclude<U, T>;
38
+ onRightHasMissing: Exclude<T, U>;
39
+ };
40
+ /**
41
+ * Type helper to compare two union types and determine their relationship.
42
+ *
43
+ * @template T - The first union type (left side)
44
+ * @template U - The second union type (right side)
45
+ * @param _diff - null if unions are identical, or an object describing the difference
46
+ * @returns void - This function is only used for type checking
47
+ */
48
+ declare function unionsAreTheSame<T, U>(_diff: UnionDiff<T, U>): void;
26
49
 
27
- export { asNonPartial, asType, isObjKey, isSubTypeOf, narrowStringToUnion, typedObjectEntries, typedObjectKeys };
50
+ export { asNonPartial, asType, isObjKey, isSubTypeOf, narrowStringToUnion, typeOnRightExtendsLeftType, typedObjectEntries, typedObjectKeys, unionsAreTheSame };
@@ -17,18 +17,23 @@ function narrowStringToUnion(key, union) {
17
17
  }
18
18
  return void 0;
19
19
  }
20
- function isSubTypeOf() {
20
+ function typeOnRightExtendsLeftType() {
21
21
  return void 0;
22
22
  }
23
+ var isSubTypeOf = typeOnRightExtendsLeftType;
23
24
  function isObjKey(key, obj) {
24
25
  return typeof key === "string" && key in obj;
25
26
  }
27
+ function unionsAreTheSame(_diff) {
28
+ }
26
29
  export {
27
30
  asNonPartial,
28
31
  asType,
29
32
  isObjKey,
30
33
  isSubTypeOf,
31
34
  narrowStringToUnion,
35
+ typeOnRightExtendsLeftType,
32
36
  typedObjectEntries,
33
- typedObjectKeys
37
+ typedObjectKeys,
38
+ unionsAreTheSame
34
39
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Typescript utils",
4
- "version": "3.14.0",
4
+ "version": "3.15.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "lib"