utilium 0.1.9 → 0.1.10
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/objects.js +6 -1
- package/package.json +1 -1
- package/src/objects.ts +5 -1
package/dist/objects.js
CHANGED
@@ -15,7 +15,12 @@ export function omit(object, ...keys) {
|
|
15
15
|
export function assignWithDefaults(to, from, defaults = to) {
|
16
16
|
const keys = new Set([...Object.keys(to), ...Object.keys(from)]);
|
17
17
|
for (const key of keys) {
|
18
|
-
|
18
|
+
try {
|
19
|
+
to[key] = from[key] ?? defaults[key] ?? to[key];
|
20
|
+
}
|
21
|
+
catch (e) {
|
22
|
+
// Do nothing
|
23
|
+
}
|
19
24
|
}
|
20
25
|
}
|
21
26
|
export function isJSON(str) {
|
package/package.json
CHANGED
package/src/objects.ts
CHANGED
@@ -24,7 +24,11 @@ export function omit<T extends object, K extends keyof T>(object: T, ...keys: re
|
|
24
24
|
export function assignWithDefaults<To extends object, From extends object>(to: To, from: From, defaults: Partial<To> = to): void {
|
25
25
|
const keys = new Set([...Object.keys(to), ...Object.keys(from)]);
|
26
26
|
for (const key of keys) {
|
27
|
-
|
27
|
+
try {
|
28
|
+
to[key] = from[key] ?? defaults[key] ?? to[key];
|
29
|
+
} catch (e) {
|
30
|
+
// Do nothing
|
31
|
+
}
|
28
32
|
}
|
29
33
|
}
|
30
34
|
|