@hg-ts/async-context 0.1.88 → 0.1.89

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/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@hg-ts/async-context",
3
- "version": "0.1.88",
3
+ "version": "0.1.89",
4
4
  "main": "dist/index.js",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"
7
7
  },
8
8
  "repository": "git@gitlab.com:hyper-graph/framework.git",
9
9
  "scripts": {
10
- "prepack": "yarn build && yarn lint:ts && yarn test",
10
+ "prepack": "yarn clear && yarn build && yarn lint:ts && yarn test",
11
+ "clear": "rm -rf dist",
11
12
  "build": "tsc",
12
13
  "build:dev": "tsc-watch",
13
14
  "lint:ts": "lint-ts",
@@ -16,11 +17,11 @@
16
17
  "test:dev": "yarn build:dev --onSuccess \"yarn test\""
17
18
  },
18
19
  "devDependencies": {
19
- "@hg-ts-config/typescript": "0.1.88",
20
- "@hg-ts/exception": "0.1.88",
21
- "@hg-ts/linter": "0.1.88",
22
- "@hg-ts/tests": "0.1.88",
23
- "@hg-ts/types": "0.1.88",
20
+ "@hg-ts-config/typescript": "0.1.89",
21
+ "@hg-ts/exception": "0.1.89",
22
+ "@hg-ts/linter": "0.1.89",
23
+ "@hg-ts/tests": "0.1.89",
24
+ "@hg-ts/types": "0.1.89",
24
25
  "@types/node": "22.10.6",
25
26
  "eslint": "9.18.0",
26
27
  "reflect-metadata": "0.2.2",
@@ -30,7 +31,7 @@
30
31
  "typescript": "5.7.3"
31
32
  },
32
33
  "peerDependencies": {
33
- "@hg-ts/exception": "0.1.88",
34
+ "@hg-ts/exception": "0.1.89",
34
35
  "reflect-metadata": "*",
35
36
  "rxjs": "*",
36
37
  "tslib": "*"
@@ -1,16 +0,0 @@
1
- import { Suite } from '@hg-ts/tests';
2
- export declare class AsyncContextTestSuite extends Suite {
3
- private context;
4
- emptyContext(): Promise<void>;
5
- noPromiseContext(): Promise<void>;
6
- promiseContext(): Promise<void>;
7
- operatorContext(): Promise<void>;
8
- operatorWithFactory(): Promise<void>;
9
- operatorWithErrorContext(): Promise<void>;
10
- operatorAfterUnsubscribe(): Promise<void>;
11
- operatorWithErrorAfterUnsubscribe(): Promise<void>;
12
- contextNotFound(): Promise<void>;
13
- beforeEach(): Promise<void>;
14
- private createOperatorTestSubscription;
15
- }
16
- //# sourceMappingURL=async-context.test-suite.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-context.test-suite.d.ts","sourceRoot":"","sources":["../src/async-context.test-suite.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,EACL,MAAM,cAAc,CAAC;AAiBtB,qBACa,qBAAsB,SAAQ,KAAK;IAC/C,OAAO,CAAC,OAAO,CAA+B;IAGjC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBjC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB/B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAUhC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUpC,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUzC,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAWzC,iCAAiC,IAAI,OAAO,CAAC,IAAI,CAAC;IAYlD,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjD,OAAO,CAAC,8BAA8B;CAgCtC"}
@@ -1,159 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AsyncContextTestSuite = void 0;
4
- const tslib_1 = require("tslib");
5
- const tests_1 = require("@hg-ts/tests");
6
- const rxjs_1 = require("rxjs");
7
- const async_context_not_found_exception_1 = require("./async-context.not-found.exception");
8
- const async_context_provider_1 = require("./async-context.provider");
9
- let AsyncContextTestSuite = class AsyncContextTestSuite extends tests_1.Suite {
10
- context;
11
- async emptyContext() {
12
- (0, tests_1.expect)(this.context.get()).toBe(null);
13
- }
14
- async noPromiseContext() {
15
- const contextValue = Math.random();
16
- const resultValue = Math.random();
17
- const result = this.context.run(contextValue, () => {
18
- (0, tests_1.expect)(this.context.getOrFail()).toBe(contextValue);
19
- this.context.exit(() => {
20
- (0, tests_1.expect)(this.context.get()).toBe(null);
21
- });
22
- return resultValue;
23
- });
24
- (0, tests_1.expect)(result).toBe(resultValue);
25
- }
26
- async promiseContext() {
27
- const contextValue = Math.random();
28
- const resultValue = Math.random();
29
- const result = await this.context.run(contextValue, async () => {
30
- (0, tests_1.expect)(this.context.getOrFail()).toBe(contextValue);
31
- await this.context.exit(async () => {
32
- (0, tests_1.expect)(this.context.get()).toBe(null);
33
- });
34
- return resultValue;
35
- });
36
- (0, tests_1.expect)(result).toBe(resultValue);
37
- }
38
- async operatorContext() {
39
- const { subject, input } = this.createOperatorTestSubscription();
40
- subject.next(input);
41
- subject.complete();
42
- tests_1.expect.assertions(4);
43
- }
44
- async operatorWithFactory() {
45
- const { subject, input } = this.createOperatorTestSubscription(value => -value);
46
- subject.next(input);
47
- subject.complete();
48
- tests_1.expect.assertions(4);
49
- }
50
- async operatorWithErrorContext() {
51
- const { subject, input } = this.createOperatorTestSubscription();
52
- subject.error(input);
53
- subject.complete();
54
- tests_1.expect.assertions(4);
55
- }
56
- async operatorAfterUnsubscribe() {
57
- const { subject, input, subscription } = this.createOperatorTestSubscription();
58
- subscription.unsubscribe();
59
- subject.next(input);
60
- subject.complete();
61
- tests_1.expect.assertions(2);
62
- }
63
- async operatorWithErrorAfterUnsubscribe() {
64
- const { subject, input, subscription } = this.createOperatorTestSubscription();
65
- subscription.unsubscribe();
66
- subject.error(input);
67
- subject.complete();
68
- tests_1.expect.assertions(2);
69
- }
70
- async contextNotFound() {
71
- this.context.getOrFail();
72
- }
73
- async beforeEach() {
74
- this.context = new async_context_provider_1.AsyncContextProvider();
75
- }
76
- createOperatorTestSubscription(factory) {
77
- const subject = new rxjs_1.Subject();
78
- const input = Math.random();
79
- const context = factory ? factory(input) : input;
80
- const withContext = (value) => {
81
- (0, tests_1.expect)(value).toBe(input);
82
- (0, tests_1.expect)(this.context.getOrFail()).toBe(context);
83
- };
84
- const withoutContext = (value) => {
85
- (0, tests_1.expect)(value).toBe(input);
86
- (0, tests_1.expect)(this.context.get()).toBe(null);
87
- };
88
- const subscription = subject.asObservable()
89
- .pipe(this.context.runOperator(factory), (0, rxjs_1.tap)({
90
- next: withContext,
91
- error: withContext,
92
- }), this.context.exitOperator(), (0, rxjs_1.tap)({
93
- next: withoutContext,
94
- error: withoutContext,
95
- }))
96
- .subscribe({ next() { }, error() { } });
97
- return { subject, subscription, input, context };
98
- }
99
- };
100
- exports.AsyncContextTestSuite = AsyncContextTestSuite;
101
- tslib_1.__decorate([
102
- (0, tests_1.Test)(),
103
- tslib_1.__metadata("design:type", Function),
104
- tslib_1.__metadata("design:paramtypes", []),
105
- tslib_1.__metadata("design:returntype", Promise)
106
- ], AsyncContextTestSuite.prototype, "emptyContext", null);
107
- tslib_1.__decorate([
108
- (0, tests_1.Test)(),
109
- tslib_1.__metadata("design:type", Function),
110
- tslib_1.__metadata("design:paramtypes", []),
111
- tslib_1.__metadata("design:returntype", Promise)
112
- ], AsyncContextTestSuite.prototype, "noPromiseContext", null);
113
- tslib_1.__decorate([
114
- (0, tests_1.Test)(),
115
- tslib_1.__metadata("design:type", Function),
116
- tslib_1.__metadata("design:paramtypes", []),
117
- tslib_1.__metadata("design:returntype", Promise)
118
- ], AsyncContextTestSuite.prototype, "promiseContext", null);
119
- tslib_1.__decorate([
120
- (0, tests_1.Test)(),
121
- tslib_1.__metadata("design:type", Function),
122
- tslib_1.__metadata("design:paramtypes", []),
123
- tslib_1.__metadata("design:returntype", Promise)
124
- ], AsyncContextTestSuite.prototype, "operatorContext", null);
125
- tslib_1.__decorate([
126
- (0, tests_1.Test)(),
127
- tslib_1.__metadata("design:type", Function),
128
- tslib_1.__metadata("design:paramtypes", []),
129
- tslib_1.__metadata("design:returntype", Promise)
130
- ], AsyncContextTestSuite.prototype, "operatorWithFactory", null);
131
- tslib_1.__decorate([
132
- (0, tests_1.Test)(),
133
- tslib_1.__metadata("design:type", Function),
134
- tslib_1.__metadata("design:paramtypes", []),
135
- tslib_1.__metadata("design:returntype", Promise)
136
- ], AsyncContextTestSuite.prototype, "operatorWithErrorContext", null);
137
- tslib_1.__decorate([
138
- (0, tests_1.Test)(),
139
- tslib_1.__metadata("design:type", Function),
140
- tslib_1.__metadata("design:paramtypes", []),
141
- tslib_1.__metadata("design:returntype", Promise)
142
- ], AsyncContextTestSuite.prototype, "operatorAfterUnsubscribe", null);
143
- tslib_1.__decorate([
144
- (0, tests_1.Test)(),
145
- tslib_1.__metadata("design:type", Function),
146
- tslib_1.__metadata("design:paramtypes", []),
147
- tslib_1.__metadata("design:returntype", Promise)
148
- ], AsyncContextTestSuite.prototype, "operatorWithErrorAfterUnsubscribe", null);
149
- tslib_1.__decorate([
150
- (0, tests_1.Test)(),
151
- (0, tests_1.ExpectException)(async_context_not_found_exception_1.AsyncContextNotFoundException),
152
- tslib_1.__metadata("design:type", Function),
153
- tslib_1.__metadata("design:paramtypes", []),
154
- tslib_1.__metadata("design:returntype", Promise)
155
- ], AsyncContextTestSuite.prototype, "contextNotFound", null);
156
- exports.AsyncContextTestSuite = AsyncContextTestSuite = tslib_1.__decorate([
157
- (0, tests_1.Describe)()
158
- ], AsyncContextTestSuite);
159
- //# sourceMappingURL=async-context.test-suite.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-context.test-suite.js","sourceRoot":"","sources":["../src/async-context.test-suite.ts"],"names":[],"mappings":";;;;AAAA,wCAMsB;AACtB,+BAIc;AAEd,2FAAoF;AACpF,qEAAgE;AAUzD,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,aAAK;IACvC,OAAO,CAA+B;IAGjC,AAAN,KAAK,CAAC,YAAY;Q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