@augment-vir/common 19.4.1 → 19.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.
@@ -18,19 +18,24 @@ function mergeDeep(...inputs) {
18
18
  let result = {};
19
19
  const mergeProps = {};
20
20
  inputs.forEach((individualInput) => {
21
- result = {
22
- ...result,
23
- ...individualInput,
24
- };
25
- Object.entries(individualInput).forEach(([key, value,]) => {
26
- if ((0, runtime_type_of_1.isRuntimeTypeOf)(value, 'object')) {
27
- const mergePropsArray = mergeProps[key] || [];
28
- if (!mergeProps[key]) {
29
- mergeProps[key] = mergePropsArray;
21
+ try {
22
+ Object.entries(individualInput).forEach(([key, value,]) => {
23
+ if ((0, runtime_type_of_1.isRuntimeTypeOf)(value, 'object')) {
24
+ const mergePropsArray = mergeProps[key] || [];
25
+ if (!mergeProps[key]) {
26
+ mergeProps[key] = mergePropsArray;
27
+ }
28
+ mergePropsArray.push(value);
30
29
  }
31
- mergePropsArray.push(value);
32
- }
33
- });
30
+ });
31
+ result = {
32
+ ...result,
33
+ ...individualInput,
34
+ };
35
+ }
36
+ catch (error) {
37
+ /** Ignore errors, such as individualInput not actually being an object. */
38
+ }
34
39
  });
35
40
  Object.entries(mergeProps).forEach(([key, mergeValues,]) => {
36
41
  result[key] = mergeDeep(...mergeValues);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.waitForCondition = exports.createDeferredPromiseWrapper = exports.wrapPromiseInTimeout = exports.PromiseTimeoutError = exports.isPromiseLike = exports.waitValue = exports.wait = void 0;
3
+ exports.waitForCondition = exports.callAsynchronously = exports.createDeferredPromiseWrapper = exports.wrapPromiseInTimeout = exports.PromiseTimeoutError = exports.isPromiseLike = exports.waitValue = exports.wait = void 0;
4
4
  const error_1 = require("./error");
5
5
  const typed_has_property_1 = require("./object/typed-has-property");
6
6
  function wait(delayMs) {
@@ -84,6 +84,14 @@ function createDeferredPromiseWrapper() {
84
84
  };
85
85
  }
86
86
  exports.createDeferredPromiseWrapper = createDeferredPromiseWrapper;
87
+ /**
88
+ * Call a function asynchronously without interrupting current synchronous execution, even if the
89
+ * function was originally synchronous.
90
+ */
91
+ async function callAsynchronously(callback) {
92
+ return await Promise.resolve().then(() => callback());
93
+ }
94
+ exports.callAsynchronously = callAsynchronously;
87
95
  async function waitForCondition({ conditionCallback, timeoutMs = 10000, intervalMs = 100, timeoutMessage = '', }) {
88
96
  let condition = false;
89
97
  let lastError;
package/dist/cjs/index.js CHANGED
@@ -37,6 +37,7 @@ __exportStar(require("./augments/object/merge-deep"), exports);
37
37
  __exportStar(require("./augments/object/nested-keys"), exports);
38
38
  __exportStar(require("./augments/object/object"), exports);
39
39
  __exportStar(require("./augments/object/object-entries"), exports);
40
+ __exportStar(require("./augments/object/old-union-to-intersection"), exports);
40
41
  __exportStar(require("./augments/object/pick-deep"), exports);
41
42
  __exportStar(require("./augments/object/typed-has-property"), exports);
42
43
  __exportStar(require("./augments/promise"), exports);
@@ -15,19 +15,24 @@ export function mergeDeep(...inputs) {
15
15
  let result = {};
16
16
  const mergeProps = {};
17
17
  inputs.forEach((individualInput) => {
18
- result = {
19
- ...result,
20
- ...individualInput,
21
- };
22
- Object.entries(individualInput).forEach(([key, value,]) => {
23
- if (isRuntimeTypeOf(value, 'object')) {
24
- const mergePropsArray = mergeProps[key] || [];
25
- if (!mergeProps[key]) {
26
- mergeProps[key] = mergePropsArray;
18
+ try {
19
+ Object.entries(individualInput).forEach(([key, value,]) => {
20
+ if (isRuntimeTypeOf(value, 'object')) {
21
+ const mergePropsArray = mergeProps[key] || [];
22
+ if (!mergeProps[key]) {
23
+ mergeProps[key] = mergePropsArray;
24
+ }
25
+ mergePropsArray.push(value);
27
26
  }
28
- mergePropsArray.push(value);
29
- }
30
- });
27
+ });
28
+ result = {
29
+ ...result,
30
+ ...individualInput,
31
+ };
32
+ }
33
+ catch (error) {
34
+ /** Ignore errors, such as individualInput not actually being an object. */
35
+ }
31
36
  });
32
37
  Object.entries(mergeProps).forEach(([key, mergeValues,]) => {
33
38
  result[key] = mergeDeep(...mergeValues);
@@ -75,6 +75,13 @@ export function createDeferredPromiseWrapper() {
75
75
  },
76
76
  };
77
77
  }
78
+ /**
79
+ * Call a function asynchronously without interrupting current synchronous execution, even if the
80
+ * function was originally synchronous.
81
+ */
82
+ export async function callAsynchronously(callback) {
83
+ return await Promise.resolve().then(() => callback());
84
+ }
78
85
  export async function waitForCondition({ conditionCallback, timeoutMs = 10000, intervalMs = 100, timeoutMessage = '', }) {
79
86
  let condition = false;
80
87
  let lastError;
package/dist/esm/index.js CHANGED
@@ -21,6 +21,7 @@ export * from './augments/object/merge-deep';
21
21
  export * from './augments/object/nested-keys';
22
22
  export * from './augments/object/object';
23
23
  export * from './augments/object/object-entries';
24
+ export * from './augments/object/old-union-to-intersection';
24
25
  export * from './augments/object/pick-deep';
25
26
  export * from './augments/object/typed-has-property';
26
27
  export * from './augments/promise';
@@ -1,5 +1,5 @@
1
- import { UnionToIntersection } from 'type-fest';
2
1
  import { PropertyValueType } from './object';
2
+ import { UnionToIntersection } from './old-union-to-intersection';
3
3
  export type NestedSequentialKeys<ObjectGeneric extends object> = PropertyValueType<{
4
4
  [Prop in keyof ObjectGeneric]: NonNullable<ObjectGeneric[Prop]> extends object ? Readonly<[Prop, ...(NestedSequentialKeys<NonNullable<ObjectGeneric[Prop]>> | [])]> : Readonly<[Prop]>;
5
5
  }>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This is the version of UnionToIntersection from type-fest v4.3.3. In version 4.4.0 type-fest
3
+ * changed this type helper and it broke how we're using it.
4
+ */
5
+ export type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection : never;
@@ -23,4 +23,9 @@ export type WaitForConditionInputs = {
23
23
  intervalMs?: number;
24
24
  timeoutMessage?: string;
25
25
  };
26
+ /**
27
+ * Call a function asynchronously without interrupting current synchronous execution, even if the
28
+ * function was originally synchronous.
29
+ */
30
+ export declare function callAsynchronously<T>(callback: () => MaybePromise<T>): Promise<T>;
26
31
  export declare function waitForCondition({ conditionCallback, timeoutMs, intervalMs, timeoutMessage, }: WaitForConditionInputs): Promise<void>;
@@ -21,6 +21,7 @@ export * from './augments/object/merge-deep';
21
21
  export * from './augments/object/nested-keys';
22
22
  export * from './augments/object/object';
23
23
  export * from './augments/object/object-entries';
24
+ export * from './augments/object/old-union-to-intersection';
24
25
  export * from './augments/object/pick-deep';
25
26
  export * from './augments/object/typed-has-property';
26
27
  export * from './augments/promise';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augment-vir/common",
3
- "version": "19.4.1",
3
+ "version": "19.5.0",
4
4
  "homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
5
5
  "bugs": {
6
6
  "url": "https://github.com/electrovir/augment-vir/issues"
@@ -24,7 +24,7 @@
24
24
  "test:types": "tsc --noEmit"
25
25
  },
26
26
  "dependencies": {
27
- "type-fest": "^4.3.3"
27
+ "type-fest": "^4.4.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^5.2.2"