@ls-stack/utils 2.3.0 → 2.4.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.
@@ -22,6 +22,8 @@ var typingFnUtils_exports = {};
22
22
  __export(typingFnUtils_exports, {
23
23
  asNonPartial: () => asNonPartial,
24
24
  asType: () => asType,
25
+ isObjKey: () => isObjKey,
26
+ isSubTypeOf: () => isSubTypeOf,
25
27
  narrowStringToUnion: () => narrowStringToUnion,
26
28
  typedObjectEntries: () => typedObjectEntries,
27
29
  typedObjectKeys: () => typedObjectKeys
@@ -45,10 +47,18 @@ function narrowStringToUnion(key, union) {
45
47
  }
46
48
  return void 0;
47
49
  }
50
+ function isSubTypeOf() {
51
+ return void 0;
52
+ }
53
+ function isObjKey(key, obj) {
54
+ return typeof key === "string" && key in obj;
55
+ }
48
56
  // Annotate the CommonJS export names for ESM import in node:
49
57
  0 && (module.exports = {
50
58
  asNonPartial,
51
59
  asType,
60
+ isObjKey,
61
+ isSubTypeOf,
52
62
  narrowStringToUnion,
53
63
  typedObjectEntries,
54
64
  typedObjectKeys
@@ -11,5 +11,17 @@ declare function typedObjectKeys<T extends Record<string, unknown>>(obj: T): (ke
11
11
  declare function asType<T = unknown>(value: T): T;
12
12
  /** narrow a string to a union of strings */
13
13
  declare function narrowStringToUnion<const T extends string>(key: string | undefined | null, union: T[]): T | undefined;
14
+ /**
15
+ * Type helper to check if a type is a subtype of another type.
16
+ *
17
+ * @template BaseType - The base type to check against
18
+ * @template SubType - The type that should extend BaseType
19
+ * @returns {unknown} Returns undefined, only used for type checking
20
+ */
21
+ declare function isSubTypeOf<BaseType, SubType extends BaseType>(): unknown;
22
+ /**
23
+ * Type helper to narrow a string to a key of an object.
24
+ */
25
+ declare function isObjKey<T extends Record<string, unknown>>(key: unknown, obj: T): key is keyof T;
14
26
 
15
- export { asNonPartial, asType, narrowStringToUnion, typedObjectEntries, typedObjectKeys };
27
+ export { asNonPartial, asType, isObjKey, isSubTypeOf, narrowStringToUnion, typedObjectEntries, typedObjectKeys };
@@ -11,5 +11,17 @@ declare function typedObjectKeys<T extends Record<string, unknown>>(obj: T): (ke
11
11
  declare function asType<T = unknown>(value: T): T;
12
12
  /** narrow a string to a union of strings */
13
13
  declare function narrowStringToUnion<const T extends string>(key: string | undefined | null, union: T[]): T | undefined;
14
+ /**
15
+ * Type helper to check if a type is a subtype of another type.
16
+ *
17
+ * @template BaseType - The base type to check against
18
+ * @template SubType - The type that should extend BaseType
19
+ * @returns {unknown} Returns undefined, only used for type checking
20
+ */
21
+ declare function isSubTypeOf<BaseType, SubType extends BaseType>(): unknown;
22
+ /**
23
+ * Type helper to narrow a string to a key of an object.
24
+ */
25
+ declare function isObjKey<T extends Record<string, unknown>>(key: unknown, obj: T): key is keyof T;
14
26
 
15
- export { asNonPartial, asType, narrowStringToUnion, typedObjectEntries, typedObjectKeys };
27
+ export { asNonPartial, asType, isObjKey, isSubTypeOf, narrowStringToUnion, typedObjectEntries, typedObjectKeys };
@@ -17,9 +17,17 @@ function narrowStringToUnion(key, union) {
17
17
  }
18
18
  return void 0;
19
19
  }
20
+ function isSubTypeOf() {
21
+ return void 0;
22
+ }
23
+ function isObjKey(key, obj) {
24
+ return typeof key === "string" && key in obj;
25
+ }
20
26
  export {
21
27
  asNonPartial,
22
28
  asType,
29
+ isObjKey,
30
+ isSubTypeOf,
23
31
  narrowStringToUnion,
24
32
  typedObjectEntries,
25
33
  typedObjectKeys
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Typescript utils",
4
- "version": "2.3.0",
4
+ "version": "2.4.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist"