@daiso-tech/core 0.34.0 → 0.35.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.
Files changed (149) hide show
  1. package/README.md +2 -4
  2. package/dist/async/_module-exports.d.ts +0 -1
  3. package/dist/async/_module-exports.js +0 -1
  4. package/dist/async/_module-exports.js.map +1 -1
  5. package/dist/async/async.errors.d.ts +19 -12
  6. package/dist/async/async.errors.js +27 -16
  7. package/dist/async/async.errors.js.map +1 -1
  8. package/dist/async/middlewares/_module.d.ts +3 -0
  9. package/dist/async/middlewares/_module.js +3 -0
  10. package/dist/async/middlewares/_module.js.map +1 -1
  11. package/dist/async/middlewares/_shared.d.ts +10 -0
  12. package/dist/async/middlewares/_shared.js +5 -0
  13. package/dist/async/middlewares/_shared.js.map +1 -0
  14. package/dist/async/middlewares/bulkhead/_module.d.ts +1 -0
  15. package/dist/async/middlewares/bulkhead/_module.js +2 -0
  16. package/dist/async/middlewares/bulkhead/_module.js.map +1 -0
  17. package/dist/async/middlewares/bulkhead/bulkhead.middleware.d.ts +80 -0
  18. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js +46 -0
  19. package/dist/async/middlewares/bulkhead/bulkhead.middleware.js.map +1 -0
  20. package/dist/async/middlewares/dynamic/dynamic.middleware.d.ts +2 -2
  21. package/dist/async/middlewares/dynamic/dynamic.middleware.js +5 -5
  22. package/dist/async/middlewares/dynamic/dynamic.middleware.js.map +1 -1
  23. package/dist/async/middlewares/fallback/fallback.middleware.d.ts +10 -8
  24. package/dist/async/middlewares/fallback/fallback.middleware.js +1 -1
  25. package/dist/async/middlewares/fallback/fallback.middleware.js.map +1 -1
  26. package/dist/async/middlewares/hedging/_module.d.ts +2 -0
  27. package/dist/async/middlewares/hedging/_module.js +3 -0
  28. package/dist/async/middlewares/hedging/_module.js.map +1 -0
  29. package/dist/async/middlewares/hedging/_shared.d.ts +93 -0
  30. package/dist/async/middlewares/hedging/_shared.js +5 -0
  31. package/dist/async/middlewares/hedging/_shared.js.map +1 -0
  32. package/dist/async/middlewares/hedging/concurrent-hedging/_module.d.ts +1 -0
  33. package/dist/async/middlewares/hedging/concurrent-hedging/_module.js +2 -0
  34. package/dist/async/middlewares/hedging/concurrent-hedging/_module.js.map +1 -0
  35. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.d.ts +51 -0
  36. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js +138 -0
  37. package/dist/async/middlewares/hedging/concurrent-hedging/concurrent-hedging.middleware.js.map +1 -0
  38. package/dist/async/middlewares/hedging/sequential-hedging/_module.d.ts +1 -0
  39. package/dist/async/middlewares/hedging/sequential-hedging/_module.js +2 -0
  40. package/dist/async/middlewares/hedging/sequential-hedging/_module.js.map +1 -0
  41. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.d.ts +51 -0
  42. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js +104 -0
  43. package/dist/async/middlewares/hedging/sequential-hedging/sequential-hedging.middleware.js.map +1 -0
  44. package/dist/async/middlewares/observe/observe.middleware.d.ts +14 -16
  45. package/dist/async/middlewares/observe/observe.middleware.js +1 -1
  46. package/dist/async/middlewares/observe/observe.middleware.js.map +1 -1
  47. package/dist/async/middlewares/retry/retry.middleware.d.ts +41 -36
  48. package/dist/async/middlewares/retry/retry.middleware.js +31 -28
  49. package/dist/async/middlewares/retry/retry.middleware.js.map +1 -1
  50. package/dist/async/middlewares/timeout/timeout.middleware.d.ts +34 -39
  51. package/dist/async/middlewares/timeout/timeout.middleware.js +30 -47
  52. package/dist/async/middlewares/timeout/timeout.middleware.js.map +1 -1
  53. package/dist/async/utilities/_module.d.ts +2 -0
  54. package/dist/async/utilities/_module.js +2 -0
  55. package/dist/async/utilities/_module.js.map +1 -1
  56. package/dist/async/utilities/abort-and-fail/abort-and-fail.d.ts +3 -0
  57. package/dist/async/utilities/abort-and-fail/abort-and-fail.js +6 -7
  58. package/dist/async/utilities/abort-and-fail/abort-and-fail.js.map +1 -1
  59. package/dist/async/utilities/lazy-promise/lazy-promise.js +0 -1
  60. package/dist/async/utilities/lazy-promise/lazy-promise.js.map +1 -1
  61. package/dist/async/utilities/promise-queue/_module.d.ts +1 -0
  62. package/dist/async/utilities/promise-queue/_module.js +2 -0
  63. package/dist/async/utilities/promise-queue/_module.js.map +1 -0
  64. package/dist/async/utilities/promise-queue/promise-queue.d.ts +32 -0
  65. package/dist/async/utilities/promise-queue/promise-queue.js +107 -0
  66. package/dist/async/utilities/promise-queue/promise-queue.js.map +1 -0
  67. package/dist/async/utilities/timeout-and-fail/_module.d.ts +1 -0
  68. package/dist/async/utilities/timeout-and-fail/_module.js +2 -0
  69. package/dist/async/utilities/timeout-and-fail/_module.js.map +1 -0
  70. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.d.ts +7 -0
  71. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js +19 -0
  72. package/dist/async/utilities/timeout-and-fail/timeout-and-fail.js.map +1 -0
  73. package/dist/cache/contracts/cache.contract.d.ts +2 -2
  74. package/dist/cache/contracts/cache.events.d.ts +43 -47
  75. package/dist/cache/contracts/cache.events.js +5 -103
  76. package/dist/cache/contracts/cache.events.js.map +1 -1
  77. package/dist/cache/implementations/derivables/cache/cache.d.ts +15 -15
  78. package/dist/cache/implementations/derivables/cache/cache.js +94 -79
  79. package/dist/cache/implementations/derivables/cache/cache.js.map +1 -1
  80. package/dist/cache/implementations/derivables/cache-factory/cache-factory.d.ts +1 -1
  81. package/dist/cache/implementations/derivables/cache-factory/cache-factory.js.map +1 -1
  82. package/dist/cache/implementations/test-utilities/cache.test-suite.js +138 -147
  83. package/dist/cache/implementations/test-utilities/cache.test-suite.js.map +1 -1
  84. package/dist/event-bus/contracts/_module-exports.d.ts +0 -1
  85. package/dist/event-bus/contracts/_module-exports.js +0 -1
  86. package/dist/event-bus/contracts/_module-exports.js.map +1 -1
  87. package/dist/event-bus/contracts/event-bus-adapter.contract.d.ts +6 -1
  88. package/dist/event-bus/contracts/event-bus-factory.contract.d.ts +2 -3
  89. package/dist/event-bus/contracts/event-bus-factory.contract.js.map +1 -1
  90. package/dist/event-bus/contracts/event-bus.contract.d.ts +12 -23
  91. package/dist/event-bus/implementations/derivables/event-bus/event-bus.d.ts +10 -10
  92. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js +30 -30
  93. package/dist/event-bus/implementations/derivables/event-bus/event-bus.js.map +1 -1
  94. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.d.ts +13 -7
  95. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js +11 -5
  96. package/dist/event-bus/implementations/derivables/event-bus-factory/event-bus-factory.js.map +1 -1
  97. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.d.ts +0 -2
  98. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js +13 -20
  99. package/dist/event-bus/implementations/test-utilities/event-bus-adapter.test-suite.js.map +1 -1
  100. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.d.ts +0 -2
  101. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js +187 -207
  102. package/dist/event-bus/implementations/test-utilities/event-bus.test-suite.js.map +1 -1
  103. package/dist/lock/contracts/lock-provider.contract.d.ts +2 -2
  104. package/dist/lock/contracts/lock.events.d.ts +35 -44
  105. package/dist/lock/contracts/lock.events.js +8 -90
  106. package/dist/lock/contracts/lock.events.js.map +1 -1
  107. package/dist/lock/implementations/derivables/lock-provider/lock-provider.d.ts +9 -9
  108. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js +12 -12
  109. package/dist/lock/implementations/derivables/lock-provider/lock-provider.js.map +1 -1
  110. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.d.ts +2 -2
  111. package/dist/lock/implementations/derivables/lock-provider/lock-serde-transformer.js.map +1 -1
  112. package/dist/lock/implementations/derivables/lock-provider/lock.d.ts +2 -2
  113. package/dist/lock/implementations/derivables/lock-provider/lock.js +69 -50
  114. package/dist/lock/implementations/derivables/lock-provider/lock.js.map +1 -1
  115. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.d.ts +1 -1
  116. package/dist/lock/implementations/derivables/lock-provider-factory/lock-provider-factory.js.map +1 -1
  117. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js +212 -212
  118. package/dist/lock/implementations/test-utilities/lock-provider.test-suite.js.map +1 -1
  119. package/dist/serde/contracts/flexible-serde.contract.d.ts +0 -11
  120. package/dist/serde/implementations/derivables/serde.d.ts +1 -32
  121. package/dist/serde/implementations/derivables/serde.js +0 -45
  122. package/dist/serde/implementations/derivables/serde.js.map +1 -1
  123. package/dist/utilities/classes/hooks/async-hooks.d.ts +107 -20
  124. package/dist/utilities/classes/hooks/async-hooks.js +47 -18
  125. package/dist/utilities/classes/hooks/async-hooks.js.map +1 -1
  126. package/dist/utilities/classes/hooks/hooks.d.ts +39 -21
  127. package/dist/utilities/classes/hooks/hooks.js +19 -18
  128. package/dist/utilities/classes/hooks/hooks.js.map +1 -1
  129. package/dist/utilities/classes/key-prefixer/key-prefixer.js +2 -2
  130. package/dist/utilities/classes/key-prefixer/key-prefixer.js.map +1 -1
  131. package/dist/utilities/contracts/_module.d.ts +0 -1
  132. package/dist/utilities/contracts/_module.js +0 -1
  133. package/dist/utilities/contracts/_module.js.map +1 -1
  134. package/dist/utilities/functions/invokable.d.ts +9 -5
  135. package/dist/utilities/functions/invokable.js +10 -0
  136. package/dist/utilities/functions/invokable.js.map +1 -1
  137. package/package.json +22 -2
  138. package/dist/async/async.events.d.ts +0 -105
  139. package/dist/async/async.events.js +0 -82
  140. package/dist/async/async.events.js.map +0 -1
  141. package/dist/event-bus/contracts/_shared.d.ts +0 -12
  142. package/dist/event-bus/contracts/_shared.js +0 -15
  143. package/dist/event-bus/contracts/_shared.js.map +0 -1
  144. package/dist/test.d.ts +0 -1
  145. package/dist/test.js +0 -34
  146. package/dist/test.js.map +0 -1
  147. package/dist/utilities/contracts/sync-event-bus-listenable.d.ts +0 -13
  148. package/dist/utilities/contracts/sync-event-bus-listenable.js +0 -5
  149. package/dist/utilities/contracts/sync-event-bus-listenable.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@daiso-tech/core",
3
3
  "private": false,
4
- "version": "0.34.0",
4
+ "version": "0.35.0",
5
5
  "author": "Yousif Abdulkarim",
6
6
  "license": "Apache-2.0",
7
7
  "type": "module",
@@ -37,7 +37,27 @@
37
37
  "TypeScript",
38
38
  "JavaScript",
39
39
  "Multitenant",
40
- "Multitenancy"
40
+ "Multitenancy",
41
+ "LazyPromise",
42
+ "AsyncMiddleware",
43
+ "AsyncHooks",
44
+ "Async middlewares",
45
+ "Async hooks",
46
+ "Middleware",
47
+ "Middlewares",
48
+ "Hooks",
49
+ "Fallback",
50
+ "Retry",
51
+ "Timeout",
52
+ "Deadline",
53
+ "resilience",
54
+ "Resilience",
55
+ "Hedging",
56
+ "Fallback hedging",
57
+ "Sequential hedging",
58
+ "Parallel hedging",
59
+ "Concurrent hedging",
60
+ "Latency hedging"
41
61
  ],
42
62
  "files": [
43
63
  "./dist"
@@ -1,105 +0,0 @@
1
- /**
2
- * @module Async
3
- */
4
- import type { AbortAsyncError, RetryAsyncError, TimeoutAsyncError } from "../async/async.errors.js";
5
- import { BaseEvent } from "../event-bus/contracts/_shared.js";
6
- /**
7
- * This event is dispatched when the `LazyPromise` has been rejected.
8
- *
9
- * IMPORT_PATH: `"@daiso-tech/core/async"`
10
- * @group Events
11
- */
12
- export declare class FailureAsyncEvent extends BaseEvent<{
13
- error: unknown;
14
- }> {
15
- }
16
- /**
17
- * This event is dispatched when the `LazyPromise` has been fulfilled.
18
- *
19
- * IMPORT_PATH: `"@daiso-tech/core/async"`
20
- * @group Events
21
- */
22
- export declare class SuccessAsyncEvent<TValue> extends BaseEvent<{
23
- value: TValue;
24
- }> {
25
- }
26
- /**
27
- * This event is dispatched when the `LazyPromise` has been fulfilled or rejected.
28
- *
29
- * IMPORT_PATH: `"@daiso-tech/core/async"`
30
- * @group Events
31
- */
32
- export declare class FinallyAsyncEvent extends BaseEvent<{}> {
33
- }
34
- /**
35
- * This event is dispatched on every retry attempt of the `LazyPromise`.
36
- *
37
- * IMPORT_PATH: `"@daiso-tech/core/async"`
38
- * @group Events
39
- */
40
- export declare class RetryAttemptAsyncEvent extends BaseEvent<{
41
- attempt: number;
42
- error: unknown;
43
- }> {
44
- }
45
- /**
46
- * This event is dispatched when the rety attempt of the `LazyPromise` has exceeded the given time limit.
47
- *
48
- * IMPORT_PATH: `"@daiso-tech/core/async"`
49
- * @group Events
50
- */
51
- export declare class RetryTimeoutAsyncEvent extends BaseEvent<{
52
- error: TimeoutAsyncError;
53
- }> {
54
- }
55
- /**
56
- * This event is dispatched when the `LazyPromise` has failed all retry attempts.
57
- *
58
- * IMPORT_PATH: `"@daiso-tech/core/async"`
59
- * @group Events
60
- */
61
- export declare class RetryFailureAsyncEvent extends BaseEvent<{
62
- error: RetryAsyncError;
63
- }> {
64
- }
65
- /**
66
- * This event is dispatched when `LazyPromise` has exceeded the given total time limit.
67
- *
68
- * IMPORT_PATH: `"@daiso-tech/core/async"`
69
- * @group Events
70
- */
71
- export declare class TotalTimeoutFailureAsyncEvent extends BaseEvent<{
72
- error: TimeoutAsyncError;
73
- }> {
74
- }
75
- /**
76
- * This event is dispatched when `LazyPromise` is aborted.
77
- *
78
- * IMPORT_PATH: `"@daiso-tech/core/async"`
79
- * @group Events
80
- */
81
- export declare class AbortAsyncEvent extends BaseEvent<{
82
- error: AbortAsyncError;
83
- }> {
84
- }
85
- /**
86
- *
87
- * IMPORT_PATH: `"@daiso-tech/core/async"`
88
- * @group Events
89
- */
90
- export declare const ASYNC_EVENTS: {
91
- readonly Failure: typeof FailureAsyncEvent;
92
- readonly Success: typeof SuccessAsyncEvent;
93
- readonly Finally: typeof FinallyAsyncEvent;
94
- readonly RetryAttempt: typeof RetryAttemptAsyncEvent;
95
- readonly RetryTimeout: typeof RetryTimeoutAsyncEvent;
96
- readonly RetryFailure: typeof RetryFailureAsyncEvent;
97
- readonly TotalTimeoutFailure: typeof TotalTimeoutFailureAsyncEvent;
98
- readonly Abort: typeof AbortAsyncEvent;
99
- };
100
- /**
101
- *
102
- * IMPORT_PATH: `"@daiso-tech/core/async"`
103
- * @group Events
104
- */
105
- export type AsyncEvents<TValue> = FailureAsyncEvent | SuccessAsyncEvent<TValue> | FinallyAsyncEvent | RetryAttemptAsyncEvent | RetryTimeoutAsyncEvent | RetryFailureAsyncEvent | TotalTimeoutFailureAsyncEvent | AbortAsyncEvent;
@@ -1,82 +0,0 @@
1
- import { BaseEvent } from "../event-bus/contracts/_shared.js";
2
- /**
3
- * This event is dispatched when the `LazyPromise` has been rejected.
4
- *
5
- * IMPORT_PATH: `"@daiso-tech/core/async"`
6
- * @group Events
7
- */
8
- export class FailureAsyncEvent extends BaseEvent {
9
- }
10
- /**
11
- * This event is dispatched when the `LazyPromise` has been fulfilled.
12
- *
13
- * IMPORT_PATH: `"@daiso-tech/core/async"`
14
- * @group Events
15
- */
16
- export class SuccessAsyncEvent extends BaseEvent {
17
- }
18
- /**
19
- * This event is dispatched when the `LazyPromise` has been fulfilled or rejected.
20
- *
21
- * IMPORT_PATH: `"@daiso-tech/core/async"`
22
- * @group Events
23
- */
24
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
25
- export class FinallyAsyncEvent extends BaseEvent {
26
- }
27
- /**
28
- * This event is dispatched on every retry attempt of the `LazyPromise`.
29
- *
30
- * IMPORT_PATH: `"@daiso-tech/core/async"`
31
- * @group Events
32
- */
33
- export class RetryAttemptAsyncEvent extends BaseEvent {
34
- }
35
- /**
36
- * This event is dispatched when the rety attempt of the `LazyPromise` has exceeded the given time limit.
37
- *
38
- * IMPORT_PATH: `"@daiso-tech/core/async"`
39
- * @group Events
40
- */
41
- export class RetryTimeoutAsyncEvent extends BaseEvent {
42
- }
43
- /**
44
- * This event is dispatched when the `LazyPromise` has failed all retry attempts.
45
- *
46
- * IMPORT_PATH: `"@daiso-tech/core/async"`
47
- * @group Events
48
- */
49
- export class RetryFailureAsyncEvent extends BaseEvent {
50
- }
51
- /**
52
- * This event is dispatched when `LazyPromise` has exceeded the given total time limit.
53
- *
54
- * IMPORT_PATH: `"@daiso-tech/core/async"`
55
- * @group Events
56
- */
57
- export class TotalTimeoutFailureAsyncEvent extends BaseEvent {
58
- }
59
- /**
60
- * This event is dispatched when `LazyPromise` is aborted.
61
- *
62
- * IMPORT_PATH: `"@daiso-tech/core/async"`
63
- * @group Events
64
- */
65
- export class AbortAsyncEvent extends BaseEvent {
66
- }
67
- /**
68
- *
69
- * IMPORT_PATH: `"@daiso-tech/core/async"`
70
- * @group Events
71
- */
72
- export const ASYNC_EVENTS = {
73
- Failure: FailureAsyncEvent,
74
- Success: SuccessAsyncEvent,
75
- Finally: FinallyAsyncEvent,
76
- RetryAttempt: RetryAttemptAsyncEvent,
77
- RetryTimeout: RetryTimeoutAsyncEvent,
78
- RetryFailure: RetryFailureAsyncEvent,
79
- TotalTimeoutFailure: TotalTimeoutFailureAsyncEvent,
80
- Abort: AbortAsyncEvent,
81
- };
82
- //# sourceMappingURL=async.events.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async.events.js","sourceRoot":"","sources":["../../src/async/async.events.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAErC;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,iBAA0B,SAAQ,SAE7C;CAAG;AAEL;;;;;GAKG;AACH,mEAAmE;AACnE,MAAM,OAAO,iBAAkB,SAAQ,SAAa;CAAG;AAEvD;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAG1C;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAE1C;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,SAE1C;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,6BAA8B,SAAQ,SAEjD;CAAG;AAEL;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAEnC;CAAG;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,sBAAsB;IACpC,YAAY,EAAE,sBAAsB;IACpC,YAAY,EAAE,sBAAsB;IACpC,mBAAmB,EAAE,6BAA6B;IAClD,KAAK,EAAE,eAAe;CAChB,CAAC"}
@@ -1,12 +0,0 @@
1
- /**
2
- * @module EventBus
3
- */
4
- /**
5
- *
6
- * IMPORT_PATH: `"@daiso-tech/core/event-bus/contracts"`
7
- * @group Contracts
8
- */
9
- export declare abstract class BaseEvent<TFields extends Record<string, unknown> = Record<string, unknown>> {
10
- readonly fields: TFields;
11
- constructor(fields: TFields);
12
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * @module EventBus
3
- */
4
- /**
5
- *
6
- * IMPORT_PATH: `"@daiso-tech/core/event-bus/contracts"`
7
- * @group Contracts
8
- */
9
- export class BaseEvent {
10
- fields;
11
- constructor(fields) {
12
- this.fields = fields;
13
- }
14
- }
15
- //# sourceMappingURL=_shared.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../../src/event-bus/contracts/_shared.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,OAAgB,SAAS;IAGN;IAArB,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;CAC3C"}
package/dist/test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/test.js DELETED
@@ -1,34 +0,0 @@
1
- import { observe, LazyPromise } from "./async/_module-exports.js";
2
- import { AsyncHooks, TimeSpan } from "./utilities/_module-exports.js";
3
- await new AsyncHooks(
4
- // Lets pretend this function can throw and takes time to execute.
5
- async (a, b) => {
6
- const shouldThrow1 = Math.round(Math.random() * 100);
7
- if (shouldThrow1 > 50) {
8
- throw new Error("Unexpected error occured");
9
- }
10
- await LazyPromise.delay(TimeSpan.fromMilliseconds(Math.random() * 1000));
11
- const shouldThrow2 = Math.round(Math.random() * 100);
12
- if (shouldThrow2 > 50) {
13
- throw new Error("Unexpected error occured");
14
- }
15
- return a / b;
16
- }, observe({
17
- onStart: (data) => {
18
- console.log("START:", data);
19
- },
20
- onSuccess: (data) => {
21
- console.log("SUCCESS:", data);
22
- },
23
- onError: (data) => {
24
- console.error("ERROR:", data);
25
- },
26
- onFinally: (data) => {
27
- console.log("FINALLY:", data);
28
- },
29
- })).invoke(20, 10);
30
- // Will log when the function execution has started.
31
- // Will log if the function succeded.
32
- // Will log if the function errored and the error.
33
- // Will log the execution time
34
- //# sourceMappingURL=test.js.map
package/dist/test.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAEtE,MAAM,IAAI,UAAU;AAChB,kEAAkE;AAClE,KAAK,EAAE,CAAS,EAAE,CAAS,EAAmB,EAAE;IAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;IACrD,IAAI,YAAY,GAAG,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,WAAW,CAAC,KAAK,CACnB,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAClD,CAAC;IACF,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;IACrD,IAAI,YAAY,GAAG,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC,EACD,OAAO,CAAC;IACJ,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IACD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;QAChB,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IACD,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;QAChB,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACJ,CAAC,CACL,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACjB,oDAAoD;AACpD,qCAAqC;AACrC,kDAAkD;AAClD,8BAA8B"}
@@ -1,13 +0,0 @@
1
- /**
2
- * @module Utilities
3
- */
4
- import type { BaseEvent, EventClass, EventInstance, EventListener } from "../../event-bus/contracts/_module-exports.js";
5
- /**
6
- *
7
- * IMPORT_PATH: `"@daiso-tech/core/utilities"`
8
- * @group Contracts
9
- */
10
- export type ISyncEventListenable<TEvents extends BaseEvent> = {
11
- addListener<TEventClass extends EventClass<TEvents>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): void;
12
- removeListener<TEventClass extends EventClass<TEvents>>(event: TEventClass, listener: EventListener<EventInstance<TEventClass>>): void;
13
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * @module Utilities
3
- */
4
- export {};
5
- //# sourceMappingURL=sync-event-bus-listenable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-event-bus-listenable.js","sourceRoot":"","sources":["../../../src/utilities/contracts/sync-event-bus-listenable.ts"],"names":[],"mappings":"AAAA;;GAEG"}