@ls-stack/utils 2.3.0 → 2.5.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.
- package/dist/{chunk-RVVH3MDA.js → chunk-ZE3DLPMN.js} +5 -1
- package/dist/objUtils.cjs +5 -0
- package/dist/objUtils.d.cts +2 -1
- package/dist/objUtils.d.ts +2 -1
- package/dist/objUtils.js +3 -1
- package/dist/testUtils.js +1 -1
- package/dist/typingFnUtils.cjs +10 -0
- package/dist/typingFnUtils.d.cts +13 -1
- package/dist/typingFnUtils.d.ts +13 -1
- package/dist/typingFnUtils.js +8 -0
- package/package.json +1 -1
|
@@ -29,11 +29,15 @@ function omit(obj, keys) {
|
|
|
29
29
|
}
|
|
30
30
|
return result;
|
|
31
31
|
}
|
|
32
|
+
function looseGetObjectProperty(obj, key) {
|
|
33
|
+
return obj[key];
|
|
34
|
+
}
|
|
32
35
|
|
|
33
36
|
export {
|
|
34
37
|
objectTypedEntries,
|
|
35
38
|
pick,
|
|
36
39
|
mapArrayToObject,
|
|
37
40
|
mapObjectToObject,
|
|
38
|
-
omit
|
|
41
|
+
omit,
|
|
42
|
+
looseGetObjectProperty
|
|
39
43
|
};
|
package/dist/objUtils.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/objUtils.ts
|
|
21
21
|
var objUtils_exports = {};
|
|
22
22
|
__export(objUtils_exports, {
|
|
23
|
+
looseGetObjectProperty: () => looseGetObjectProperty,
|
|
23
24
|
mapArrayToObject: () => mapArrayToObject,
|
|
24
25
|
mapObjectToObject: () => mapObjectToObject,
|
|
25
26
|
objectTypedEntries: () => objectTypedEntries,
|
|
@@ -57,8 +58,12 @@ function omit(obj, keys) {
|
|
|
57
58
|
}
|
|
58
59
|
return result;
|
|
59
60
|
}
|
|
61
|
+
function looseGetObjectProperty(obj, key) {
|
|
62
|
+
return obj[key];
|
|
63
|
+
}
|
|
60
64
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
65
|
0 && (module.exports = {
|
|
66
|
+
looseGetObjectProperty,
|
|
62
67
|
mapArrayToObject,
|
|
63
68
|
mapObjectToObject,
|
|
64
69
|
objectTypedEntries,
|
package/dist/objUtils.d.cts
CHANGED
|
@@ -3,5 +3,6 @@ declare function pick<T, K extends keyof T>(obj: T | undefined, keys: K[], renam
|
|
|
3
3
|
declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (item: T, index: number) => [K, O]): Record<K, O>;
|
|
4
4
|
declare function mapObjectToObject<I extends Record<string | number | symbol, unknown>, K extends string | number | symbol, O>(obj: I, mapper: (key: keyof I, value: I[keyof I]) => [K, O]): Record<K, O>;
|
|
5
5
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
6
|
+
declare function looseGetObjectProperty<T extends Record<string, unknown>>(obj: T, key: string): T[keyof T] | undefined;
|
|
6
7
|
|
|
7
|
-
export { mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick };
|
|
8
|
+
export { looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick };
|
package/dist/objUtils.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ declare function pick<T, K extends keyof T>(obj: T | undefined, keys: K[], renam
|
|
|
3
3
|
declare function mapArrayToObject<T, K extends string, O>(array: T[], mapper: (item: T, index: number) => [K, O]): Record<K, O>;
|
|
4
4
|
declare function mapObjectToObject<I extends Record<string | number | symbol, unknown>, K extends string | number | symbol, O>(obj: I, mapper: (key: keyof I, value: I[keyof I]) => [K, O]): Record<K, O>;
|
|
5
5
|
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
6
|
+
declare function looseGetObjectProperty<T extends Record<string, unknown>>(obj: T, key: string): T[keyof T] | undefined;
|
|
6
7
|
|
|
7
|
-
export { mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick };
|
|
8
|
+
export { looseGetObjectProperty, mapArrayToObject, mapObjectToObject, objectTypedEntries, omit, pick };
|
package/dist/objUtils.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
looseGetObjectProperty,
|
|
2
3
|
mapArrayToObject,
|
|
3
4
|
mapObjectToObject,
|
|
4
5
|
objectTypedEntries,
|
|
5
6
|
omit,
|
|
6
7
|
pick
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZE3DLPMN.js";
|
|
8
9
|
export {
|
|
10
|
+
looseGetObjectProperty,
|
|
9
11
|
mapArrayToObject,
|
|
10
12
|
mapObjectToObject,
|
|
11
13
|
objectTypedEntries,
|
package/dist/testUtils.js
CHANGED
package/dist/typingFnUtils.cjs
CHANGED
|
@@ -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
|
package/dist/typingFnUtils.d.cts
CHANGED
|
@@ -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 };
|
package/dist/typingFnUtils.d.ts
CHANGED
|
@@ -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 };
|
package/dist/typingFnUtils.js
CHANGED
|
@@ -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
|