@dungarees/rxjs 0.11.4
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/fake.d.ts +10 -0
- package/fake.js +23 -0
- package/fake.test.d.ts +1 -0
- package/fake.test.js +24 -0
- package/package.json +448 -0
- package/util.d.ts +200 -0
- package/util.js +50 -0
- package/util.test.d.ts +1 -0
- package/util.test.js +160 -0
package/fake.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GetTransformSetContext } from './util.ts';
|
|
2
|
+
import { type Observable } from 'rxjs';
|
|
3
|
+
type Options<INPUT, OUTPUT> = {
|
|
4
|
+
get: () => Observable<INPUT>;
|
|
5
|
+
set: (content: OUTPUT) => Observable<void>;
|
|
6
|
+
} | {
|
|
7
|
+
content: INPUT;
|
|
8
|
+
};
|
|
9
|
+
export declare const createGetTransformSetContextInspector: <CONTEXT, INPUT, OUTPUT>(options: Options<INPUT, OUTPUT>) => [GetTransformSetContext<CONTEXT, INPUT, OUTPUT>, Observable<OUTPUT>];
|
|
10
|
+
export {};
|
package/fake.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createGetTransformSetContext } from './util.js';
|
|
2
|
+
import { of, ReplaySubject, Subject } from 'rxjs';
|
|
3
|
+
export const createGetTransformSetContextInspector = (options) => {
|
|
4
|
+
const getOptions = (options) => {
|
|
5
|
+
return 'content' in options
|
|
6
|
+
? {
|
|
7
|
+
subject: new ReplaySubject(1),
|
|
8
|
+
get: () => of(options.content),
|
|
9
|
+
set: () => of(undefined),
|
|
10
|
+
}
|
|
11
|
+
: {
|
|
12
|
+
subject: new Subject(),
|
|
13
|
+
get: options.get,
|
|
14
|
+
set: options.set,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const { subject, get, set } = getOptions(options);
|
|
18
|
+
const transformer = createGetTransformSetContext(get, (content) => {
|
|
19
|
+
subject.next(content);
|
|
20
|
+
return set(content);
|
|
21
|
+
});
|
|
22
|
+
return [transformer, subject];
|
|
23
|
+
};
|
package/fake.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/fake.test.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createGetTransformSetContextInspector } from './fake.js';
|
|
2
|
+
import { mtest } from '@dungarees/core/marbles-vitest.ts';
|
|
3
|
+
import { map } from 'rxjs';
|
|
4
|
+
mtest('createGetTransformSetContextInspector created with get and set', ({ expect, coldStepAndClose }) => {
|
|
5
|
+
const [transformer, contentInspector$] = createGetTransformSetContextInspector({
|
|
6
|
+
get: () => coldStepAndClose('input content'),
|
|
7
|
+
set: () => coldStepAndClose(undefined),
|
|
8
|
+
});
|
|
9
|
+
const transform$ = transformer(map((content) => ({ set: content.toUpperCase(), context: 'context' })));
|
|
10
|
+
expect(transform$).toBeObservableStepAndClose({ set: 'INPUT CONTENT', context: 'context', get: 'input content' }, 2);
|
|
11
|
+
expect(contentInspector$).toBeObservableStep('INPUT CONTENT');
|
|
12
|
+
});
|
|
13
|
+
mtest('createGetTransformSetContextInspector created with content', ({ expect }) => {
|
|
14
|
+
const [transformer, contentInspector$] = createGetTransformSetContextInspector({
|
|
15
|
+
content: 'input content',
|
|
16
|
+
});
|
|
17
|
+
const transform$ = transformer(map((content) => ({ set: content.toUpperCase(), context: 'context' })));
|
|
18
|
+
expect(transform$).toBeObservableValueAndClose({
|
|
19
|
+
set: 'INPUT CONTENT',
|
|
20
|
+
context: 'context',
|
|
21
|
+
get: 'input content',
|
|
22
|
+
});
|
|
23
|
+
expect(contentInspector$).toBeObservableValue('INPUT CONTENT');
|
|
24
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dungarees/rxjs",
|
|
3
|
+
"engines": {
|
|
4
|
+
"node": ">=25.0.0"
|
|
5
|
+
},
|
|
6
|
+
"scripts": {
|
|
7
|
+
"type-check": "tsc --noEmit"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@dungarees/core": "*",
|
|
12
|
+
"rxjs": "^7.8.1",
|
|
13
|
+
"zod": "^3.25.76"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"typescript": "^5.9.3",
|
|
17
|
+
"vitest": "^3.0.2"
|
|
18
|
+
},
|
|
19
|
+
"author": "info@productkind.com",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"version": "0.11.4",
|
|
22
|
+
"exports": {
|
|
23
|
+
"./fake.test.ts": {
|
|
24
|
+
"import": "./fake.test.js",
|
|
25
|
+
"types": "./fake.test.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./fake.ts": {
|
|
28
|
+
"import": "./fake.js",
|
|
29
|
+
"types": "./fake.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./node_modules/typescript/lib/lib.d.ts": {
|
|
32
|
+
"import": "./node_modules/typescript/lib/lib.d.js",
|
|
33
|
+
"types": "./node_modules/typescript/lib/lib.d.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./node_modules/typescript/lib/lib.decorators.d.ts": {
|
|
36
|
+
"import": "./node_modules/typescript/lib/lib.decorators.d.js",
|
|
37
|
+
"types": "./node_modules/typescript/lib/lib.decorators.d.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./node_modules/typescript/lib/lib.decorators.legacy.d.ts": {
|
|
40
|
+
"import": "./node_modules/typescript/lib/lib.decorators.legacy.d.js",
|
|
41
|
+
"types": "./node_modules/typescript/lib/lib.decorators.legacy.d.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./node_modules/typescript/lib/lib.dom.asynciterable.d.ts": {
|
|
44
|
+
"import": "./node_modules/typescript/lib/lib.dom.asynciterable.d.js",
|
|
45
|
+
"types": "./node_modules/typescript/lib/lib.dom.asynciterable.d.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"./node_modules/typescript/lib/lib.dom.d.ts": {
|
|
48
|
+
"import": "./node_modules/typescript/lib/lib.dom.d.js",
|
|
49
|
+
"types": "./node_modules/typescript/lib/lib.dom.d.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./node_modules/typescript/lib/lib.dom.iterable.d.ts": {
|
|
52
|
+
"import": "./node_modules/typescript/lib/lib.dom.iterable.d.js",
|
|
53
|
+
"types": "./node_modules/typescript/lib/lib.dom.iterable.d.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./node_modules/typescript/lib/lib.es2015.collection.d.ts": {
|
|
56
|
+
"import": "./node_modules/typescript/lib/lib.es2015.collection.d.js",
|
|
57
|
+
"types": "./node_modules/typescript/lib/lib.es2015.collection.d.d.ts"
|
|
58
|
+
},
|
|
59
|
+
"./node_modules/typescript/lib/lib.es2015.core.d.ts": {
|
|
60
|
+
"import": "./node_modules/typescript/lib/lib.es2015.core.d.js",
|
|
61
|
+
"types": "./node_modules/typescript/lib/lib.es2015.core.d.d.ts"
|
|
62
|
+
},
|
|
63
|
+
"./node_modules/typescript/lib/lib.es2015.d.ts": {
|
|
64
|
+
"import": "./node_modules/typescript/lib/lib.es2015.d.js",
|
|
65
|
+
"types": "./node_modules/typescript/lib/lib.es2015.d.d.ts"
|
|
66
|
+
},
|
|
67
|
+
"./node_modules/typescript/lib/lib.es2015.generator.d.ts": {
|
|
68
|
+
"import": "./node_modules/typescript/lib/lib.es2015.generator.d.js",
|
|
69
|
+
"types": "./node_modules/typescript/lib/lib.es2015.generator.d.d.ts"
|
|
70
|
+
},
|
|
71
|
+
"./node_modules/typescript/lib/lib.es2015.iterable.d.ts": {
|
|
72
|
+
"import": "./node_modules/typescript/lib/lib.es2015.iterable.d.js",
|
|
73
|
+
"types": "./node_modules/typescript/lib/lib.es2015.iterable.d.d.ts"
|
|
74
|
+
},
|
|
75
|
+
"./node_modules/typescript/lib/lib.es2015.promise.d.ts": {
|
|
76
|
+
"import": "./node_modules/typescript/lib/lib.es2015.promise.d.js",
|
|
77
|
+
"types": "./node_modules/typescript/lib/lib.es2015.promise.d.d.ts"
|
|
78
|
+
},
|
|
79
|
+
"./node_modules/typescript/lib/lib.es2015.proxy.d.ts": {
|
|
80
|
+
"import": "./node_modules/typescript/lib/lib.es2015.proxy.d.js",
|
|
81
|
+
"types": "./node_modules/typescript/lib/lib.es2015.proxy.d.d.ts"
|
|
82
|
+
},
|
|
83
|
+
"./node_modules/typescript/lib/lib.es2015.reflect.d.ts": {
|
|
84
|
+
"import": "./node_modules/typescript/lib/lib.es2015.reflect.d.js",
|
|
85
|
+
"types": "./node_modules/typescript/lib/lib.es2015.reflect.d.d.ts"
|
|
86
|
+
},
|
|
87
|
+
"./node_modules/typescript/lib/lib.es2015.symbol.d.ts": {
|
|
88
|
+
"import": "./node_modules/typescript/lib/lib.es2015.symbol.d.js",
|
|
89
|
+
"types": "./node_modules/typescript/lib/lib.es2015.symbol.d.d.ts"
|
|
90
|
+
},
|
|
91
|
+
"./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": {
|
|
92
|
+
"import": "./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.js",
|
|
93
|
+
"types": "./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.d.ts"
|
|
94
|
+
},
|
|
95
|
+
"./node_modules/typescript/lib/lib.es2016.array.include.d.ts": {
|
|
96
|
+
"import": "./node_modules/typescript/lib/lib.es2016.array.include.d.js",
|
|
97
|
+
"types": "./node_modules/typescript/lib/lib.es2016.array.include.d.d.ts"
|
|
98
|
+
},
|
|
99
|
+
"./node_modules/typescript/lib/lib.es2016.d.ts": {
|
|
100
|
+
"import": "./node_modules/typescript/lib/lib.es2016.d.js",
|
|
101
|
+
"types": "./node_modules/typescript/lib/lib.es2016.d.d.ts"
|
|
102
|
+
},
|
|
103
|
+
"./node_modules/typescript/lib/lib.es2016.full.d.ts": {
|
|
104
|
+
"import": "./node_modules/typescript/lib/lib.es2016.full.d.js",
|
|
105
|
+
"types": "./node_modules/typescript/lib/lib.es2016.full.d.d.ts"
|
|
106
|
+
},
|
|
107
|
+
"./node_modules/typescript/lib/lib.es2016.intl.d.ts": {
|
|
108
|
+
"import": "./node_modules/typescript/lib/lib.es2016.intl.d.js",
|
|
109
|
+
"types": "./node_modules/typescript/lib/lib.es2016.intl.d.d.ts"
|
|
110
|
+
},
|
|
111
|
+
"./node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts": {
|
|
112
|
+
"import": "./node_modules/typescript/lib/lib.es2017.arraybuffer.d.js",
|
|
113
|
+
"types": "./node_modules/typescript/lib/lib.es2017.arraybuffer.d.d.ts"
|
|
114
|
+
},
|
|
115
|
+
"./node_modules/typescript/lib/lib.es2017.d.ts": {
|
|
116
|
+
"import": "./node_modules/typescript/lib/lib.es2017.d.js",
|
|
117
|
+
"types": "./node_modules/typescript/lib/lib.es2017.d.d.ts"
|
|
118
|
+
},
|
|
119
|
+
"./node_modules/typescript/lib/lib.es2017.date.d.ts": {
|
|
120
|
+
"import": "./node_modules/typescript/lib/lib.es2017.date.d.js",
|
|
121
|
+
"types": "./node_modules/typescript/lib/lib.es2017.date.d.d.ts"
|
|
122
|
+
},
|
|
123
|
+
"./node_modules/typescript/lib/lib.es2017.full.d.ts": {
|
|
124
|
+
"import": "./node_modules/typescript/lib/lib.es2017.full.d.js",
|
|
125
|
+
"types": "./node_modules/typescript/lib/lib.es2017.full.d.d.ts"
|
|
126
|
+
},
|
|
127
|
+
"./node_modules/typescript/lib/lib.es2017.intl.d.ts": {
|
|
128
|
+
"import": "./node_modules/typescript/lib/lib.es2017.intl.d.js",
|
|
129
|
+
"types": "./node_modules/typescript/lib/lib.es2017.intl.d.d.ts"
|
|
130
|
+
},
|
|
131
|
+
"./node_modules/typescript/lib/lib.es2017.object.d.ts": {
|
|
132
|
+
"import": "./node_modules/typescript/lib/lib.es2017.object.d.js",
|
|
133
|
+
"types": "./node_modules/typescript/lib/lib.es2017.object.d.d.ts"
|
|
134
|
+
},
|
|
135
|
+
"./node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": {
|
|
136
|
+
"import": "./node_modules/typescript/lib/lib.es2017.sharedmemory.d.js",
|
|
137
|
+
"types": "./node_modules/typescript/lib/lib.es2017.sharedmemory.d.d.ts"
|
|
138
|
+
},
|
|
139
|
+
"./node_modules/typescript/lib/lib.es2017.string.d.ts": {
|
|
140
|
+
"import": "./node_modules/typescript/lib/lib.es2017.string.d.js",
|
|
141
|
+
"types": "./node_modules/typescript/lib/lib.es2017.string.d.d.ts"
|
|
142
|
+
},
|
|
143
|
+
"./node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": {
|
|
144
|
+
"import": "./node_modules/typescript/lib/lib.es2017.typedarrays.d.js",
|
|
145
|
+
"types": "./node_modules/typescript/lib/lib.es2017.typedarrays.d.d.ts"
|
|
146
|
+
},
|
|
147
|
+
"./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": {
|
|
148
|
+
"import": "./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.js",
|
|
149
|
+
"types": "./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.d.ts"
|
|
150
|
+
},
|
|
151
|
+
"./node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": {
|
|
152
|
+
"import": "./node_modules/typescript/lib/lib.es2018.asynciterable.d.js",
|
|
153
|
+
"types": "./node_modules/typescript/lib/lib.es2018.asynciterable.d.d.ts"
|
|
154
|
+
},
|
|
155
|
+
"./node_modules/typescript/lib/lib.es2018.d.ts": {
|
|
156
|
+
"import": "./node_modules/typescript/lib/lib.es2018.d.js",
|
|
157
|
+
"types": "./node_modules/typescript/lib/lib.es2018.d.d.ts"
|
|
158
|
+
},
|
|
159
|
+
"./node_modules/typescript/lib/lib.es2018.full.d.ts": {
|
|
160
|
+
"import": "./node_modules/typescript/lib/lib.es2018.full.d.js",
|
|
161
|
+
"types": "./node_modules/typescript/lib/lib.es2018.full.d.d.ts"
|
|
162
|
+
},
|
|
163
|
+
"./node_modules/typescript/lib/lib.es2018.intl.d.ts": {
|
|
164
|
+
"import": "./node_modules/typescript/lib/lib.es2018.intl.d.js",
|
|
165
|
+
"types": "./node_modules/typescript/lib/lib.es2018.intl.d.d.ts"
|
|
166
|
+
},
|
|
167
|
+
"./node_modules/typescript/lib/lib.es2018.promise.d.ts": {
|
|
168
|
+
"import": "./node_modules/typescript/lib/lib.es2018.promise.d.js",
|
|
169
|
+
"types": "./node_modules/typescript/lib/lib.es2018.promise.d.d.ts"
|
|
170
|
+
},
|
|
171
|
+
"./node_modules/typescript/lib/lib.es2018.regexp.d.ts": {
|
|
172
|
+
"import": "./node_modules/typescript/lib/lib.es2018.regexp.d.js",
|
|
173
|
+
"types": "./node_modules/typescript/lib/lib.es2018.regexp.d.d.ts"
|
|
174
|
+
},
|
|
175
|
+
"./node_modules/typescript/lib/lib.es2019.array.d.ts": {
|
|
176
|
+
"import": "./node_modules/typescript/lib/lib.es2019.array.d.js",
|
|
177
|
+
"types": "./node_modules/typescript/lib/lib.es2019.array.d.d.ts"
|
|
178
|
+
},
|
|
179
|
+
"./node_modules/typescript/lib/lib.es2019.d.ts": {
|
|
180
|
+
"import": "./node_modules/typescript/lib/lib.es2019.d.js",
|
|
181
|
+
"types": "./node_modules/typescript/lib/lib.es2019.d.d.ts"
|
|
182
|
+
},
|
|
183
|
+
"./node_modules/typescript/lib/lib.es2019.full.d.ts": {
|
|
184
|
+
"import": "./node_modules/typescript/lib/lib.es2019.full.d.js",
|
|
185
|
+
"types": "./node_modules/typescript/lib/lib.es2019.full.d.d.ts"
|
|
186
|
+
},
|
|
187
|
+
"./node_modules/typescript/lib/lib.es2019.intl.d.ts": {
|
|
188
|
+
"import": "./node_modules/typescript/lib/lib.es2019.intl.d.js",
|
|
189
|
+
"types": "./node_modules/typescript/lib/lib.es2019.intl.d.d.ts"
|
|
190
|
+
},
|
|
191
|
+
"./node_modules/typescript/lib/lib.es2019.object.d.ts": {
|
|
192
|
+
"import": "./node_modules/typescript/lib/lib.es2019.object.d.js",
|
|
193
|
+
"types": "./node_modules/typescript/lib/lib.es2019.object.d.d.ts"
|
|
194
|
+
},
|
|
195
|
+
"./node_modules/typescript/lib/lib.es2019.string.d.ts": {
|
|
196
|
+
"import": "./node_modules/typescript/lib/lib.es2019.string.d.js",
|
|
197
|
+
"types": "./node_modules/typescript/lib/lib.es2019.string.d.d.ts"
|
|
198
|
+
},
|
|
199
|
+
"./node_modules/typescript/lib/lib.es2019.symbol.d.ts": {
|
|
200
|
+
"import": "./node_modules/typescript/lib/lib.es2019.symbol.d.js",
|
|
201
|
+
"types": "./node_modules/typescript/lib/lib.es2019.symbol.d.d.ts"
|
|
202
|
+
},
|
|
203
|
+
"./node_modules/typescript/lib/lib.es2020.bigint.d.ts": {
|
|
204
|
+
"import": "./node_modules/typescript/lib/lib.es2020.bigint.d.js",
|
|
205
|
+
"types": "./node_modules/typescript/lib/lib.es2020.bigint.d.d.ts"
|
|
206
|
+
},
|
|
207
|
+
"./node_modules/typescript/lib/lib.es2020.d.ts": {
|
|
208
|
+
"import": "./node_modules/typescript/lib/lib.es2020.d.js",
|
|
209
|
+
"types": "./node_modules/typescript/lib/lib.es2020.d.d.ts"
|
|
210
|
+
},
|
|
211
|
+
"./node_modules/typescript/lib/lib.es2020.date.d.ts": {
|
|
212
|
+
"import": "./node_modules/typescript/lib/lib.es2020.date.d.js",
|
|
213
|
+
"types": "./node_modules/typescript/lib/lib.es2020.date.d.d.ts"
|
|
214
|
+
},
|
|
215
|
+
"./node_modules/typescript/lib/lib.es2020.full.d.ts": {
|
|
216
|
+
"import": "./node_modules/typescript/lib/lib.es2020.full.d.js",
|
|
217
|
+
"types": "./node_modules/typescript/lib/lib.es2020.full.d.d.ts"
|
|
218
|
+
},
|
|
219
|
+
"./node_modules/typescript/lib/lib.es2020.intl.d.ts": {
|
|
220
|
+
"import": "./node_modules/typescript/lib/lib.es2020.intl.d.js",
|
|
221
|
+
"types": "./node_modules/typescript/lib/lib.es2020.intl.d.d.ts"
|
|
222
|
+
},
|
|
223
|
+
"./node_modules/typescript/lib/lib.es2020.number.d.ts": {
|
|
224
|
+
"import": "./node_modules/typescript/lib/lib.es2020.number.d.js",
|
|
225
|
+
"types": "./node_modules/typescript/lib/lib.es2020.number.d.d.ts"
|
|
226
|
+
},
|
|
227
|
+
"./node_modules/typescript/lib/lib.es2020.promise.d.ts": {
|
|
228
|
+
"import": "./node_modules/typescript/lib/lib.es2020.promise.d.js",
|
|
229
|
+
"types": "./node_modules/typescript/lib/lib.es2020.promise.d.d.ts"
|
|
230
|
+
},
|
|
231
|
+
"./node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts": {
|
|
232
|
+
"import": "./node_modules/typescript/lib/lib.es2020.sharedmemory.d.js",
|
|
233
|
+
"types": "./node_modules/typescript/lib/lib.es2020.sharedmemory.d.d.ts"
|
|
234
|
+
},
|
|
235
|
+
"./node_modules/typescript/lib/lib.es2020.string.d.ts": {
|
|
236
|
+
"import": "./node_modules/typescript/lib/lib.es2020.string.d.js",
|
|
237
|
+
"types": "./node_modules/typescript/lib/lib.es2020.string.d.d.ts"
|
|
238
|
+
},
|
|
239
|
+
"./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts": {
|
|
240
|
+
"import": "./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.js",
|
|
241
|
+
"types": "./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.d.ts"
|
|
242
|
+
},
|
|
243
|
+
"./node_modules/typescript/lib/lib.es2021.d.ts": {
|
|
244
|
+
"import": "./node_modules/typescript/lib/lib.es2021.d.js",
|
|
245
|
+
"types": "./node_modules/typescript/lib/lib.es2021.d.d.ts"
|
|
246
|
+
},
|
|
247
|
+
"./node_modules/typescript/lib/lib.es2021.full.d.ts": {
|
|
248
|
+
"import": "./node_modules/typescript/lib/lib.es2021.full.d.js",
|
|
249
|
+
"types": "./node_modules/typescript/lib/lib.es2021.full.d.d.ts"
|
|
250
|
+
},
|
|
251
|
+
"./node_modules/typescript/lib/lib.es2021.intl.d.ts": {
|
|
252
|
+
"import": "./node_modules/typescript/lib/lib.es2021.intl.d.js",
|
|
253
|
+
"types": "./node_modules/typescript/lib/lib.es2021.intl.d.d.ts"
|
|
254
|
+
},
|
|
255
|
+
"./node_modules/typescript/lib/lib.es2021.promise.d.ts": {
|
|
256
|
+
"import": "./node_modules/typescript/lib/lib.es2021.promise.d.js",
|
|
257
|
+
"types": "./node_modules/typescript/lib/lib.es2021.promise.d.d.ts"
|
|
258
|
+
},
|
|
259
|
+
"./node_modules/typescript/lib/lib.es2021.string.d.ts": {
|
|
260
|
+
"import": "./node_modules/typescript/lib/lib.es2021.string.d.js",
|
|
261
|
+
"types": "./node_modules/typescript/lib/lib.es2021.string.d.d.ts"
|
|
262
|
+
},
|
|
263
|
+
"./node_modules/typescript/lib/lib.es2021.weakref.d.ts": {
|
|
264
|
+
"import": "./node_modules/typescript/lib/lib.es2021.weakref.d.js",
|
|
265
|
+
"types": "./node_modules/typescript/lib/lib.es2021.weakref.d.d.ts"
|
|
266
|
+
},
|
|
267
|
+
"./node_modules/typescript/lib/lib.es2022.array.d.ts": {
|
|
268
|
+
"import": "./node_modules/typescript/lib/lib.es2022.array.d.js",
|
|
269
|
+
"types": "./node_modules/typescript/lib/lib.es2022.array.d.d.ts"
|
|
270
|
+
},
|
|
271
|
+
"./node_modules/typescript/lib/lib.es2022.d.ts": {
|
|
272
|
+
"import": "./node_modules/typescript/lib/lib.es2022.d.js",
|
|
273
|
+
"types": "./node_modules/typescript/lib/lib.es2022.d.d.ts"
|
|
274
|
+
},
|
|
275
|
+
"./node_modules/typescript/lib/lib.es2022.error.d.ts": {
|
|
276
|
+
"import": "./node_modules/typescript/lib/lib.es2022.error.d.js",
|
|
277
|
+
"types": "./node_modules/typescript/lib/lib.es2022.error.d.d.ts"
|
|
278
|
+
},
|
|
279
|
+
"./node_modules/typescript/lib/lib.es2022.full.d.ts": {
|
|
280
|
+
"import": "./node_modules/typescript/lib/lib.es2022.full.d.js",
|
|
281
|
+
"types": "./node_modules/typescript/lib/lib.es2022.full.d.d.ts"
|
|
282
|
+
},
|
|
283
|
+
"./node_modules/typescript/lib/lib.es2022.intl.d.ts": {
|
|
284
|
+
"import": "./node_modules/typescript/lib/lib.es2022.intl.d.js",
|
|
285
|
+
"types": "./node_modules/typescript/lib/lib.es2022.intl.d.d.ts"
|
|
286
|
+
},
|
|
287
|
+
"./node_modules/typescript/lib/lib.es2022.object.d.ts": {
|
|
288
|
+
"import": "./node_modules/typescript/lib/lib.es2022.object.d.js",
|
|
289
|
+
"types": "./node_modules/typescript/lib/lib.es2022.object.d.d.ts"
|
|
290
|
+
},
|
|
291
|
+
"./node_modules/typescript/lib/lib.es2022.regexp.d.ts": {
|
|
292
|
+
"import": "./node_modules/typescript/lib/lib.es2022.regexp.d.js",
|
|
293
|
+
"types": "./node_modules/typescript/lib/lib.es2022.regexp.d.d.ts"
|
|
294
|
+
},
|
|
295
|
+
"./node_modules/typescript/lib/lib.es2022.string.d.ts": {
|
|
296
|
+
"import": "./node_modules/typescript/lib/lib.es2022.string.d.js",
|
|
297
|
+
"types": "./node_modules/typescript/lib/lib.es2022.string.d.d.ts"
|
|
298
|
+
},
|
|
299
|
+
"./node_modules/typescript/lib/lib.es2023.array.d.ts": {
|
|
300
|
+
"import": "./node_modules/typescript/lib/lib.es2023.array.d.js",
|
|
301
|
+
"types": "./node_modules/typescript/lib/lib.es2023.array.d.d.ts"
|
|
302
|
+
},
|
|
303
|
+
"./node_modules/typescript/lib/lib.es2023.collection.d.ts": {
|
|
304
|
+
"import": "./node_modules/typescript/lib/lib.es2023.collection.d.js",
|
|
305
|
+
"types": "./node_modules/typescript/lib/lib.es2023.collection.d.d.ts"
|
|
306
|
+
},
|
|
307
|
+
"./node_modules/typescript/lib/lib.es2023.d.ts": {
|
|
308
|
+
"import": "./node_modules/typescript/lib/lib.es2023.d.js",
|
|
309
|
+
"types": "./node_modules/typescript/lib/lib.es2023.d.d.ts"
|
|
310
|
+
},
|
|
311
|
+
"./node_modules/typescript/lib/lib.es2023.full.d.ts": {
|
|
312
|
+
"import": "./node_modules/typescript/lib/lib.es2023.full.d.js",
|
|
313
|
+
"types": "./node_modules/typescript/lib/lib.es2023.full.d.d.ts"
|
|
314
|
+
},
|
|
315
|
+
"./node_modules/typescript/lib/lib.es2023.intl.d.ts": {
|
|
316
|
+
"import": "./node_modules/typescript/lib/lib.es2023.intl.d.js",
|
|
317
|
+
"types": "./node_modules/typescript/lib/lib.es2023.intl.d.d.ts"
|
|
318
|
+
},
|
|
319
|
+
"./node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts": {
|
|
320
|
+
"import": "./node_modules/typescript/lib/lib.es2024.arraybuffer.d.js",
|
|
321
|
+
"types": "./node_modules/typescript/lib/lib.es2024.arraybuffer.d.d.ts"
|
|
322
|
+
},
|
|
323
|
+
"./node_modules/typescript/lib/lib.es2024.collection.d.ts": {
|
|
324
|
+
"import": "./node_modules/typescript/lib/lib.es2024.collection.d.js",
|
|
325
|
+
"types": "./node_modules/typescript/lib/lib.es2024.collection.d.d.ts"
|
|
326
|
+
},
|
|
327
|
+
"./node_modules/typescript/lib/lib.es2024.d.ts": {
|
|
328
|
+
"import": "./node_modules/typescript/lib/lib.es2024.d.js",
|
|
329
|
+
"types": "./node_modules/typescript/lib/lib.es2024.d.d.ts"
|
|
330
|
+
},
|
|
331
|
+
"./node_modules/typescript/lib/lib.es2024.full.d.ts": {
|
|
332
|
+
"import": "./node_modules/typescript/lib/lib.es2024.full.d.js",
|
|
333
|
+
"types": "./node_modules/typescript/lib/lib.es2024.full.d.d.ts"
|
|
334
|
+
},
|
|
335
|
+
"./node_modules/typescript/lib/lib.es2024.object.d.ts": {
|
|
336
|
+
"import": "./node_modules/typescript/lib/lib.es2024.object.d.js",
|
|
337
|
+
"types": "./node_modules/typescript/lib/lib.es2024.object.d.d.ts"
|
|
338
|
+
},
|
|
339
|
+
"./node_modules/typescript/lib/lib.es2024.promise.d.ts": {
|
|
340
|
+
"import": "./node_modules/typescript/lib/lib.es2024.promise.d.js",
|
|
341
|
+
"types": "./node_modules/typescript/lib/lib.es2024.promise.d.d.ts"
|
|
342
|
+
},
|
|
343
|
+
"./node_modules/typescript/lib/lib.es2024.regexp.d.ts": {
|
|
344
|
+
"import": "./node_modules/typescript/lib/lib.es2024.regexp.d.js",
|
|
345
|
+
"types": "./node_modules/typescript/lib/lib.es2024.regexp.d.d.ts"
|
|
346
|
+
},
|
|
347
|
+
"./node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts": {
|
|
348
|
+
"import": "./node_modules/typescript/lib/lib.es2024.sharedmemory.d.js",
|
|
349
|
+
"types": "./node_modules/typescript/lib/lib.es2024.sharedmemory.d.d.ts"
|
|
350
|
+
},
|
|
351
|
+
"./node_modules/typescript/lib/lib.es2024.string.d.ts": {
|
|
352
|
+
"import": "./node_modules/typescript/lib/lib.es2024.string.d.js",
|
|
353
|
+
"types": "./node_modules/typescript/lib/lib.es2024.string.d.d.ts"
|
|
354
|
+
},
|
|
355
|
+
"./node_modules/typescript/lib/lib.es5.d.ts": {
|
|
356
|
+
"import": "./node_modules/typescript/lib/lib.es5.d.js",
|
|
357
|
+
"types": "./node_modules/typescript/lib/lib.es5.d.d.ts"
|
|
358
|
+
},
|
|
359
|
+
"./node_modules/typescript/lib/lib.es6.d.ts": {
|
|
360
|
+
"import": "./node_modules/typescript/lib/lib.es6.d.js",
|
|
361
|
+
"types": "./node_modules/typescript/lib/lib.es6.d.d.ts"
|
|
362
|
+
},
|
|
363
|
+
"./node_modules/typescript/lib/lib.esnext.array.d.ts": {
|
|
364
|
+
"import": "./node_modules/typescript/lib/lib.esnext.array.d.js",
|
|
365
|
+
"types": "./node_modules/typescript/lib/lib.esnext.array.d.d.ts"
|
|
366
|
+
},
|
|
367
|
+
"./node_modules/typescript/lib/lib.esnext.collection.d.ts": {
|
|
368
|
+
"import": "./node_modules/typescript/lib/lib.esnext.collection.d.js",
|
|
369
|
+
"types": "./node_modules/typescript/lib/lib.esnext.collection.d.d.ts"
|
|
370
|
+
},
|
|
371
|
+
"./node_modules/typescript/lib/lib.esnext.d.ts": {
|
|
372
|
+
"import": "./node_modules/typescript/lib/lib.esnext.d.js",
|
|
373
|
+
"types": "./node_modules/typescript/lib/lib.esnext.d.d.ts"
|
|
374
|
+
},
|
|
375
|
+
"./node_modules/typescript/lib/lib.esnext.decorators.d.ts": {
|
|
376
|
+
"import": "./node_modules/typescript/lib/lib.esnext.decorators.d.js",
|
|
377
|
+
"types": "./node_modules/typescript/lib/lib.esnext.decorators.d.d.ts"
|
|
378
|
+
},
|
|
379
|
+
"./node_modules/typescript/lib/lib.esnext.disposable.d.ts": {
|
|
380
|
+
"import": "./node_modules/typescript/lib/lib.esnext.disposable.d.js",
|
|
381
|
+
"types": "./node_modules/typescript/lib/lib.esnext.disposable.d.d.ts"
|
|
382
|
+
},
|
|
383
|
+
"./node_modules/typescript/lib/lib.esnext.error.d.ts": {
|
|
384
|
+
"import": "./node_modules/typescript/lib/lib.esnext.error.d.js",
|
|
385
|
+
"types": "./node_modules/typescript/lib/lib.esnext.error.d.d.ts"
|
|
386
|
+
},
|
|
387
|
+
"./node_modules/typescript/lib/lib.esnext.float16.d.ts": {
|
|
388
|
+
"import": "./node_modules/typescript/lib/lib.esnext.float16.d.js",
|
|
389
|
+
"types": "./node_modules/typescript/lib/lib.esnext.float16.d.d.ts"
|
|
390
|
+
},
|
|
391
|
+
"./node_modules/typescript/lib/lib.esnext.full.d.ts": {
|
|
392
|
+
"import": "./node_modules/typescript/lib/lib.esnext.full.d.js",
|
|
393
|
+
"types": "./node_modules/typescript/lib/lib.esnext.full.d.d.ts"
|
|
394
|
+
},
|
|
395
|
+
"./node_modules/typescript/lib/lib.esnext.intl.d.ts": {
|
|
396
|
+
"import": "./node_modules/typescript/lib/lib.esnext.intl.d.js",
|
|
397
|
+
"types": "./node_modules/typescript/lib/lib.esnext.intl.d.d.ts"
|
|
398
|
+
},
|
|
399
|
+
"./node_modules/typescript/lib/lib.esnext.iterator.d.ts": {
|
|
400
|
+
"import": "./node_modules/typescript/lib/lib.esnext.iterator.d.js",
|
|
401
|
+
"types": "./node_modules/typescript/lib/lib.esnext.iterator.d.d.ts"
|
|
402
|
+
},
|
|
403
|
+
"./node_modules/typescript/lib/lib.esnext.promise.d.ts": {
|
|
404
|
+
"import": "./node_modules/typescript/lib/lib.esnext.promise.d.js",
|
|
405
|
+
"types": "./node_modules/typescript/lib/lib.esnext.promise.d.d.ts"
|
|
406
|
+
},
|
|
407
|
+
"./node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts": {
|
|
408
|
+
"import": "./node_modules/typescript/lib/lib.esnext.sharedmemory.d.js",
|
|
409
|
+
"types": "./node_modules/typescript/lib/lib.esnext.sharedmemory.d.d.ts"
|
|
410
|
+
},
|
|
411
|
+
"./node_modules/typescript/lib/lib.scripthost.d.ts": {
|
|
412
|
+
"import": "./node_modules/typescript/lib/lib.scripthost.d.js",
|
|
413
|
+
"types": "./node_modules/typescript/lib/lib.scripthost.d.d.ts"
|
|
414
|
+
},
|
|
415
|
+
"./node_modules/typescript/lib/lib.webworker.asynciterable.d.ts": {
|
|
416
|
+
"import": "./node_modules/typescript/lib/lib.webworker.asynciterable.d.js",
|
|
417
|
+
"types": "./node_modules/typescript/lib/lib.webworker.asynciterable.d.d.ts"
|
|
418
|
+
},
|
|
419
|
+
"./node_modules/typescript/lib/lib.webworker.d.ts": {
|
|
420
|
+
"import": "./node_modules/typescript/lib/lib.webworker.d.js",
|
|
421
|
+
"types": "./node_modules/typescript/lib/lib.webworker.d.d.ts"
|
|
422
|
+
},
|
|
423
|
+
"./node_modules/typescript/lib/lib.webworker.importscripts.d.ts": {
|
|
424
|
+
"import": "./node_modules/typescript/lib/lib.webworker.importscripts.d.js",
|
|
425
|
+
"types": "./node_modules/typescript/lib/lib.webworker.importscripts.d.d.ts"
|
|
426
|
+
},
|
|
427
|
+
"./node_modules/typescript/lib/lib.webworker.iterable.d.ts": {
|
|
428
|
+
"import": "./node_modules/typescript/lib/lib.webworker.iterable.d.js",
|
|
429
|
+
"types": "./node_modules/typescript/lib/lib.webworker.iterable.d.d.ts"
|
|
430
|
+
},
|
|
431
|
+
"./node_modules/typescript/lib/tsserverlibrary.d.ts": {
|
|
432
|
+
"import": "./node_modules/typescript/lib/tsserverlibrary.d.js",
|
|
433
|
+
"types": "./node_modules/typescript/lib/tsserverlibrary.d.d.ts"
|
|
434
|
+
},
|
|
435
|
+
"./node_modules/typescript/lib/typescript.d.ts": {
|
|
436
|
+
"import": "./node_modules/typescript/lib/typescript.d.js",
|
|
437
|
+
"types": "./node_modules/typescript/lib/typescript.d.d.ts"
|
|
438
|
+
},
|
|
439
|
+
"./util.test.ts": {
|
|
440
|
+
"import": "./util.test.js",
|
|
441
|
+
"types": "./util.test.d.ts"
|
|
442
|
+
},
|
|
443
|
+
"./util.ts": {
|
|
444
|
+
"import": "./util.js",
|
|
445
|
+
"types": "./util.d.ts"
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
package/util.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { FilterRecord, Guard } from '@dungarees/core/type-util.ts';
|
|
2
|
+
import { type Observable, type OperatorFunction } from 'rxjs';
|
|
3
|
+
import { type ZodSchema } from 'zod';
|
|
4
|
+
export declare const UNSAFE_MARBLE_TESTING_OBSERVABLE_FUNCTION: unique symbol;
|
|
5
|
+
export type UnsafeMarbleTestingObservableFunction<T extends (...args: never[]) => unknown = (...args: never[]) => unknown> = T & {
|
|
6
|
+
[UNSAFE_MARBLE_TESTING_OBSERVABLE_FUNCTION]: true;
|
|
7
|
+
};
|
|
8
|
+
export type SafeMarbleTestingObservableFunction<T extends (...args: never[]) => unknown> = T & {
|
|
9
|
+
[UNSAFE_MARBLE_TESTING_OBSERVABLE_FUNCTION]: false;
|
|
10
|
+
};
|
|
11
|
+
export type UnsafeService<SERVICE extends Record<string, (...args: never[]) => unknown>> = {
|
|
12
|
+
[K in keyof SERVICE]: SERVICE[K] extends (...args: never[]) => Observable<unknown> ? UnsafeMarbleTestingObservableFunction<SERVICE[K]> : SERVICE[K];
|
|
13
|
+
};
|
|
14
|
+
export declare const markUnsafeForMarbleTesting: <T extends (...args: never[]) => unknown>(fn: T) => UnsafeMarbleTestingObservableFunction<T>;
|
|
15
|
+
export type SyncFunctionToObservable<FUNC extends (...args: never[]) => unknown> = FUNC extends (...args: infer ARGS) => infer RETURN ? (...args: ARGS) => Observable<RETURN> : never;
|
|
16
|
+
export declare const collectValuesFrom: <T>(values$: Observable<T>) => Promise<T[]>;
|
|
17
|
+
export declare const asyncFunctionToObservable: <RETURN, ARGS extends unknown[]>(asyncFn: (...args: ARGS) => Promise<RETURN>) => UnsafeMarbleTestingObservableFunction<(...args: ARGS) => Observable<RETURN>>;
|
|
18
|
+
export declare const syncFunctionToObservable: <F extends (...args: never[]) => unknown>(syncFn: F, delayMs?: number) => SyncFunctionToObservable<F>;
|
|
19
|
+
export declare const catchAndRethrow: <T>(rethrowFn: (error: unknown) => Error) => OperatorFunction<T, T>;
|
|
20
|
+
export declare const catchValueAndRethrow: <VALUE, INPUT>(valueFn: (error: unknown) => VALUE, rethrowFn: (error: unknown) => Error) => OperatorFunction<INPUT, VALUE | INPUT>;
|
|
21
|
+
type TryPipe = {
|
|
22
|
+
<INPUT, OUTPUT>(...operators: []): OperatorFunction<INPUT, OUTPUT>;
|
|
23
|
+
<INPUT, OUTPUT>(...operators: [OperatorFunction<INPUT, OUTPUT>]): OperatorFunction<INPUT, OUTPUT>;
|
|
24
|
+
<INPUT, OUTPUT, A>(...operators: [OperatorFunction<INPUT, A>, OperatorFunction<A, OUTPUT>]): OperatorFunction<INPUT, OUTPUT>;
|
|
25
|
+
<INPUT, OUTPUT, A, B>(...operators: [OperatorFunction<INPUT, A>, OperatorFunction<A, B>, OperatorFunction<B, OUTPUT>]): OperatorFunction<INPUT, OUTPUT>;
|
|
26
|
+
<INPUT, OUTPUT, A, B, C>(...operators: [
|
|
27
|
+
OperatorFunction<INPUT, A>,
|
|
28
|
+
OperatorFunction<A, B>,
|
|
29
|
+
OperatorFunction<B, C>,
|
|
30
|
+
OperatorFunction<C, OUTPUT>
|
|
31
|
+
]): OperatorFunction<INPUT, OUTPUT>;
|
|
32
|
+
<INPUT, OUTPUT, A, B, C, D>(...operators: [
|
|
33
|
+
OperatorFunction<INPUT, A>,
|
|
34
|
+
OperatorFunction<A, B>,
|
|
35
|
+
OperatorFunction<B, C>,
|
|
36
|
+
OperatorFunction<C, D>,
|
|
37
|
+
OperatorFunction<D, OUTPUT>
|
|
38
|
+
]): OperatorFunction<INPUT, OUTPUT>;
|
|
39
|
+
<INPUT, OUTPUT, A, B, C, D, E>(...operators: [
|
|
40
|
+
OperatorFunction<INPUT, A>,
|
|
41
|
+
OperatorFunction<A, B>,
|
|
42
|
+
OperatorFunction<B, C>,
|
|
43
|
+
OperatorFunction<C, D>,
|
|
44
|
+
OperatorFunction<D, E>,
|
|
45
|
+
OperatorFunction<E, OUTPUT>
|
|
46
|
+
]): OperatorFunction<INPUT, OUTPUT>;
|
|
47
|
+
<INPUT, OUTPUT, A, B, C, D, E, F>(...operators: [
|
|
48
|
+
OperatorFunction<INPUT, A>,
|
|
49
|
+
OperatorFunction<A, B>,
|
|
50
|
+
OperatorFunction<B, C>,
|
|
51
|
+
OperatorFunction<C, D>,
|
|
52
|
+
OperatorFunction<D, E>,
|
|
53
|
+
OperatorFunction<E, F>,
|
|
54
|
+
OperatorFunction<F, OUTPUT>
|
|
55
|
+
]): OperatorFunction<INPUT, OUTPUT>;
|
|
56
|
+
<INPUT, OUTPUT, A, B, C, D, E, F>(...operators: [
|
|
57
|
+
OperatorFunction<INPUT, A>,
|
|
58
|
+
OperatorFunction<A, B>,
|
|
59
|
+
OperatorFunction<B, C>,
|
|
60
|
+
OperatorFunction<C, D>,
|
|
61
|
+
OperatorFunction<D, E>,
|
|
62
|
+
OperatorFunction<E, F>,
|
|
63
|
+
...[
|
|
64
|
+
OperatorFunction<F, unknown>,
|
|
65
|
+
...OperatorFunction<never, unknown>[],
|
|
66
|
+
OperatorFunction<never, OUTPUT>
|
|
67
|
+
]
|
|
68
|
+
]): OperatorFunction<INPUT, OUTPUT>;
|
|
69
|
+
};
|
|
70
|
+
export declare const tryPipe: TryPipe;
|
|
71
|
+
export declare const assertMap: <T>(predicate: (value: T) => boolean, message: string) => OperatorFunction<T, T>;
|
|
72
|
+
export declare const assertTypeByGuardMap: <T>(guard: Guard<T>, message: string) => OperatorFunction<unknown, T>;
|
|
73
|
+
export declare const assertSchemaMap: <T>(schema: ZodSchema<T>, message: string) => OperatorFunction<unknown, T>;
|
|
74
|
+
export type GetTransformSet<GET, SET> = {
|
|
75
|
+
(): Observable<{
|
|
76
|
+
get: GET;
|
|
77
|
+
set: SET;
|
|
78
|
+
}>;
|
|
79
|
+
(op1: OperatorFunction<GET, SET>): Observable<{
|
|
80
|
+
get: GET;
|
|
81
|
+
set: SET;
|
|
82
|
+
}>;
|
|
83
|
+
<A>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, SET>): Observable<{
|
|
84
|
+
get: GET;
|
|
85
|
+
set: SET;
|
|
86
|
+
}>;
|
|
87
|
+
<A, B>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, SET>): Observable<{
|
|
88
|
+
get: GET;
|
|
89
|
+
set: SET;
|
|
90
|
+
}>;
|
|
91
|
+
<A, B, C>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, SET>): Observable<{
|
|
92
|
+
get: GET;
|
|
93
|
+
set: SET;
|
|
94
|
+
}>;
|
|
95
|
+
<A, B, C, D>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, SET>): Observable<{
|
|
96
|
+
get: GET;
|
|
97
|
+
set: SET;
|
|
98
|
+
}>;
|
|
99
|
+
<A, B, C, D, E>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, SET>): Observable<{
|
|
100
|
+
get: GET;
|
|
101
|
+
set: SET;
|
|
102
|
+
}>;
|
|
103
|
+
<A, B, C, D, E, F>(...operators: [
|
|
104
|
+
OperatorFunction<GET, A>,
|
|
105
|
+
OperatorFunction<A, B>,
|
|
106
|
+
OperatorFunction<B, C>,
|
|
107
|
+
OperatorFunction<C, D>,
|
|
108
|
+
OperatorFunction<D, E>,
|
|
109
|
+
OperatorFunction<E, F>,
|
|
110
|
+
...[
|
|
111
|
+
OperatorFunction<F, unknown>,
|
|
112
|
+
...OperatorFunction<never, unknown>[],
|
|
113
|
+
OperatorFunction<never, SET>
|
|
114
|
+
]
|
|
115
|
+
]): Observable<{
|
|
116
|
+
get: GET;
|
|
117
|
+
set: SET;
|
|
118
|
+
}>;
|
|
119
|
+
};
|
|
120
|
+
export declare const createGetTransformSet: <GET, SET>(getter: () => Observable<GET>, setter: (value: SET) => Observable<void>) => GetTransformSet<GET, SET>;
|
|
121
|
+
export type GetTransformSetContext<CONTEXT, GET, SET> = {
|
|
122
|
+
(op1: OperatorFunction<GET, {
|
|
123
|
+
set: SET;
|
|
124
|
+
context: CONTEXT;
|
|
125
|
+
}>): Observable<{
|
|
126
|
+
get: GET;
|
|
127
|
+
set: SET;
|
|
128
|
+
context: CONTEXT;
|
|
129
|
+
}>;
|
|
130
|
+
<A>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, {
|
|
131
|
+
set: SET;
|
|
132
|
+
context: CONTEXT;
|
|
133
|
+
}>): Observable<{
|
|
134
|
+
get: GET;
|
|
135
|
+
set: SET;
|
|
136
|
+
context: CONTEXT;
|
|
137
|
+
}>;
|
|
138
|
+
<A, B>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, {
|
|
139
|
+
set: SET;
|
|
140
|
+
context: CONTEXT;
|
|
141
|
+
}>): Observable<{
|
|
142
|
+
get: GET;
|
|
143
|
+
set: SET;
|
|
144
|
+
context: CONTEXT;
|
|
145
|
+
}>;
|
|
146
|
+
<A, B, C>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, {
|
|
147
|
+
set: SET;
|
|
148
|
+
context: CONTEXT;
|
|
149
|
+
}>): Observable<{
|
|
150
|
+
get: GET;
|
|
151
|
+
set: SET;
|
|
152
|
+
context: CONTEXT;
|
|
153
|
+
}>;
|
|
154
|
+
<A, B, C, D>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, {
|
|
155
|
+
set: SET;
|
|
156
|
+
context: CONTEXT;
|
|
157
|
+
}>): Observable<{
|
|
158
|
+
get: GET;
|
|
159
|
+
set: SET;
|
|
160
|
+
context: CONTEXT;
|
|
161
|
+
}>;
|
|
162
|
+
<A, B, C, D, E>(op1: OperatorFunction<GET, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, {
|
|
163
|
+
set: SET;
|
|
164
|
+
context: CONTEXT;
|
|
165
|
+
}>): Observable<{
|
|
166
|
+
get: GET;
|
|
167
|
+
set: SET;
|
|
168
|
+
context: CONTEXT;
|
|
169
|
+
}>;
|
|
170
|
+
<A, B, C, D, E, F>(...operators: [
|
|
171
|
+
OperatorFunction<GET, A>,
|
|
172
|
+
OperatorFunction<A, B>,
|
|
173
|
+
OperatorFunction<B, C>,
|
|
174
|
+
OperatorFunction<C, D>,
|
|
175
|
+
OperatorFunction<D, E>,
|
|
176
|
+
OperatorFunction<E, F>,
|
|
177
|
+
...[
|
|
178
|
+
OperatorFunction<F, unknown>,
|
|
179
|
+
...OperatorFunction<never, unknown>[],
|
|
180
|
+
OperatorFunction<never, {
|
|
181
|
+
set: SET;
|
|
182
|
+
context: CONTEXT;
|
|
183
|
+
}>
|
|
184
|
+
]
|
|
185
|
+
]): Observable<{
|
|
186
|
+
get: GET;
|
|
187
|
+
set: SET;
|
|
188
|
+
context: CONTEXT;
|
|
189
|
+
}>;
|
|
190
|
+
};
|
|
191
|
+
export declare const createGetTransformSetContext: <CONTEXT, GET, SET>(getter: () => Observable<GET>, setter: (value: SET) => Observable<void>) => GetTransformSetContext<CONTEXT, GET, SET>;
|
|
192
|
+
type SyncMethodBase<SERVICE> = {
|
|
193
|
+
[K in keyof SERVICE]: K extends `${infer BASE}Sync` ? BASE : never;
|
|
194
|
+
}[keyof SERVICE];
|
|
195
|
+
type ObservableMethodsFromSync<SERVICE extends Record<`${string}Sync`, (...args: never[]) => unknown>, METHOD_NAMES extends readonly SyncMethodBase<SERVICE>[]> = {
|
|
196
|
+
[K in METHOD_NAMES[number]]: `${K & string}Sync` extends keyof SERVICE ? SERVICE[`${K & string}Sync`] extends (...args: infer ARGS) => infer RETURN ? (...args: ARGS) => Observable<RETURN> : never : never;
|
|
197
|
+
};
|
|
198
|
+
export declare function getObservableMethodsFromSync<SERVICE extends Record<`${string}Sync`, (...args: never[]) => unknown>, const METHOD_NAMES extends readonly SyncMethodBase<SERVICE>[]>(service: SERVICE, methodNames: METHOD_NAMES, delayMs?: number): ObservableMethodsFromSync<SERVICE, METHOD_NAMES>;
|
|
199
|
+
export declare const getUnsafeMethodNames: <const SERVICE extends Record<string, unknown>>(service: SERVICE) => Array<keyof FilterRecord<SERVICE, UnsafeMarbleTestingObservableFunction>>;
|
|
200
|
+
export {};
|
package/util.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { assertDefined, assertPredicate, assertTypeByGuard, mapConstKeysToEntries, } from '@dungarees/core/util.ts';
|
|
2
|
+
import { catchError, concat, defer, delay, lastValueFrom, map, mergeMap, of, scan, throwError, } from 'rxjs';
|
|
3
|
+
export const UNSAFE_MARBLE_TESTING_OBSERVABLE_FUNCTION = Symbol('UNSAFE_MARBLE_TESTING_OBSERVABLE_FUNCTION');
|
|
4
|
+
export const markUnsafeForMarbleTesting = (fn) => {
|
|
5
|
+
;
|
|
6
|
+
fn[UNSAFE_MARBLE_TESTING_OBSERVABLE_FUNCTION] =
|
|
7
|
+
true;
|
|
8
|
+
return fn;
|
|
9
|
+
};
|
|
10
|
+
export const collectValuesFrom = async (values$) => await lastValueFrom(values$.pipe(scan((acc, value) => [...acc, value], [])));
|
|
11
|
+
export const asyncFunctionToObservable = (asyncFn) => {
|
|
12
|
+
const wrapped = (...args) => {
|
|
13
|
+
return defer(async () => await asyncFn(...args));
|
|
14
|
+
};
|
|
15
|
+
return markUnsafeForMarbleTesting(wrapped);
|
|
16
|
+
};
|
|
17
|
+
export const syncFunctionToObservable = (syncFn, delayMs = 0) => {
|
|
18
|
+
const wrapped = (...args) => defer(() => of(syncFn(...args))).pipe(delay(delayMs));
|
|
19
|
+
return wrapped;
|
|
20
|
+
};
|
|
21
|
+
export const catchAndRethrow = (rethrowFn) => catchError((error) => throwError(() => rethrowFn(error)));
|
|
22
|
+
export const catchValueAndRethrow = (valueFn, rethrowFn) => catchError((error) => concat(of(valueFn(error)), throwError(() => rethrowFn(error))));
|
|
23
|
+
export const tryPipe = (...operators) => mergeMap((value) => defer(() => of(value).pipe(...operators)));
|
|
24
|
+
export const assertMap = (predicate, message) => map((value) => assertPredicate({
|
|
25
|
+
value,
|
|
26
|
+
predicate,
|
|
27
|
+
message,
|
|
28
|
+
}));
|
|
29
|
+
export const assertTypeByGuardMap = (guard, message) => map((value) => assertTypeByGuard({
|
|
30
|
+
value,
|
|
31
|
+
guard,
|
|
32
|
+
message,
|
|
33
|
+
}));
|
|
34
|
+
export const assertSchemaMap = (schema, message) => map((value) => {
|
|
35
|
+
return assertTypeByGuard({
|
|
36
|
+
value,
|
|
37
|
+
guard: (v) => schema.safeParse(v).success,
|
|
38
|
+
message,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
export const createGetTransformSet = (getter, setter) => (...operators) => getter().pipe(mergeMap((getValue) => of(getValue).pipe(...operators, mergeMap((setValue) => setter(setValue).pipe(map(() => ({ get: getValue, set: setValue })))))));
|
|
42
|
+
export const createGetTransformSetContext = (getter, setter) => (...operators) => getter().pipe(mergeMap((getValue) => of(getValue).pipe(...operators, mergeMap(({ set: setValue, context }) => setter(setValue).pipe(map(() => ({ get: getValue, set: setValue, context })))))));
|
|
43
|
+
export function getObservableMethodsFromSync(service, methodNames, delayMs = 0) {
|
|
44
|
+
const observableMethods = mapConstKeysToEntries(methodNames, (methodName) => syncFunctionToObservable(assertDefined(service[`${methodName}Sync`], `Method "${methodName}Sync" don't exists`), delayMs));
|
|
45
|
+
return Object.fromEntries(observableMethods);
|
|
46
|
+
}
|
|
47
|
+
const isMarkedUnsafeForMarbleTesting = (value) => typeof value === 'function' &&
|
|
48
|
+
UNSAFE_MARBLE_TESTING_OBSERVABLE_FUNCTION in value &&
|
|
49
|
+
value[UNSAFE_MARBLE_TESTING_OBSERVABLE_FUNCTION] === true;
|
|
50
|
+
export const getUnsafeMethodNames = (service) => Object.keys(service).filter((key) => isMarkedUnsafeForMarbleTesting(service[key]));
|
package/util.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/util.test.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { assertMap, assertSchemaMap, assertTypeByGuardMap, asyncFunctionToObservable, catchAndRethrow, catchValueAndRethrow, collectValuesFrom, createGetTransformSet, createGetTransformSetContext, getObservableMethodsFromSync, getUnsafeMethodNames, markUnsafeForMarbleTesting, syncFunctionToObservable, tryPipe, } from './util.js';
|
|
2
|
+
import { getErrorMessage } from '@dungarees/core/error.ts';
|
|
3
|
+
import { mtest } from '@dungarees/core/marbles-vitest.ts';
|
|
4
|
+
import { catchError, lastValueFrom, map, of, Subject } from 'rxjs';
|
|
5
|
+
import { expect, expectTypeOf, test } from 'vitest';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
test('collectValuesFrom', async () => {
|
|
8
|
+
const input = of(1, 2, 3, 4, 5);
|
|
9
|
+
const values = await collectValuesFrom(input);
|
|
10
|
+
expectTypeOf().toEqualTypeOf();
|
|
11
|
+
expect(values).toEqual([1, 2, 3, 4, 5]);
|
|
12
|
+
});
|
|
13
|
+
test('asyncFunctionToObservable', async () => {
|
|
14
|
+
const asyncFn = async (a, b) => a + b;
|
|
15
|
+
const observableFn = asyncFunctionToObservable(asyncFn);
|
|
16
|
+
const result$ = observableFn(2, 3);
|
|
17
|
+
expect(await lastValueFrom(result$)).toBe(5);
|
|
18
|
+
});
|
|
19
|
+
mtest('syncFunctionToObservable', ({ expect }) => {
|
|
20
|
+
const syncFn = (a, b) => a + b;
|
|
21
|
+
const observableFn = syncFunctionToObservable(syncFn);
|
|
22
|
+
const result$ = observableFn(2, 3);
|
|
23
|
+
expect(result$).toBeObservable('(5|)', { '5': 5 });
|
|
24
|
+
const observableFnDelayed = syncFunctionToObservable(syncFn, 1);
|
|
25
|
+
const resultDelayed$ = observableFnDelayed(2, 3);
|
|
26
|
+
expect(resultDelayed$).toBeObservable('-(5|)', { '5': 5 });
|
|
27
|
+
const resultError$ = syncFunctionToObservable(() => {
|
|
28
|
+
throw new Error('Test error');
|
|
29
|
+
})();
|
|
30
|
+
expect(resultError$).toBeObservable('#', {}, new Error('Test error'));
|
|
31
|
+
});
|
|
32
|
+
mtest('catchAndRethrow', ({ expect, cold }) => {
|
|
33
|
+
const input$ = cold('-#', {}, new Error('Test error'));
|
|
34
|
+
const result$ = input$.pipe(catchAndRethrow((error) => new Error(`Caught error: ${getErrorMessage(error)}`)));
|
|
35
|
+
expect(result$).toBeObservable('-#', {}, new Error('Caught error: Test error'));
|
|
36
|
+
});
|
|
37
|
+
mtest('catchValueAndRethrow', ({ expect, cold }) => {
|
|
38
|
+
const input$ = cold('-#', {}, new Error('Test error'));
|
|
39
|
+
const result$ = input$.pipe(catchValueAndRethrow((error) => getErrorMessage(error), (error) => new Error(`Caught error: ${getErrorMessage(error)}`)));
|
|
40
|
+
expect(result$).toBeObservable('-(1#)', { '1': 'Test error' }, new Error('Caught error: Test error'));
|
|
41
|
+
});
|
|
42
|
+
mtest('tryPipe no error', ({ expect }) => {
|
|
43
|
+
const result$ = of(1).pipe(tryPipe(map((x) => x + 1), catchError((error) => of(`Error: ${getErrorMessage(error)}`))));
|
|
44
|
+
expect(result$).toBeObservable('(2|)', { '2': 2 });
|
|
45
|
+
});
|
|
46
|
+
mtest('tryPipe with error', ({ expect }) => {
|
|
47
|
+
const result$ = of(1).pipe(tryPipe(map(() => {
|
|
48
|
+
throw new Error('Test error');
|
|
49
|
+
}), catchError((error) => of(`Error: ${getErrorMessage(error)}`))));
|
|
50
|
+
expect(result$).toBeObservable('(e|)', { e: 'Error: Test error' });
|
|
51
|
+
});
|
|
52
|
+
mtest('tryPipe with error outside', ({ expect }) => {
|
|
53
|
+
const result$ = of(1).pipe(map(() => {
|
|
54
|
+
throw new Error('Test error');
|
|
55
|
+
}), tryPipe(catchError((error) => of(`Error: ${getErrorMessage(error)}`))));
|
|
56
|
+
expect(result$).toBeObservable('#', {}, new Error('Test error'));
|
|
57
|
+
});
|
|
58
|
+
mtest('assertMap with valid input', ({ expect }) => {
|
|
59
|
+
const input$ = of(30);
|
|
60
|
+
const result$ = input$.pipe(assertMap((age) => age >= 18, 'Age must be at least 18'));
|
|
61
|
+
expect(result$).toBeObservable('(a|)', { a: 30 });
|
|
62
|
+
});
|
|
63
|
+
mtest('assertMap with invalid input', ({ expect }) => {
|
|
64
|
+
const input$ = of(10);
|
|
65
|
+
const result$ = input$.pipe(assertMap((age) => age >= 18, 'Age must be at least 18'));
|
|
66
|
+
expect(result$).toBeObservable('#', {}, new Error('Age must be at least 18'));
|
|
67
|
+
});
|
|
68
|
+
mtest('assertTypeByGuardMap with valid input', ({ expect }) => {
|
|
69
|
+
const input$ = of({ name: 'John' });
|
|
70
|
+
const result$ = input$.pipe(assertTypeByGuardMap((obj) => typeof obj === 'object' && obj !== null && 'name' in obj && typeof obj.name === 'string', 'Name is required and must be a string'), map((obj) => {
|
|
71
|
+
expectTypeOf().toEqualTypeOf();
|
|
72
|
+
return obj;
|
|
73
|
+
}));
|
|
74
|
+
expect(result$).toBeObservable('(a|)', { a: { name: 'John' } });
|
|
75
|
+
});
|
|
76
|
+
mtest('assertTypeByGuardMap with invalid input', ({ expect }) => {
|
|
77
|
+
const input$ = of({ age: 30 });
|
|
78
|
+
const result$ = input$.pipe(assertTypeByGuardMap((obj) => typeof obj === 'object' && obj !== null && 'name' in obj && typeof obj.name === 'string', 'Name is required and must be a string'));
|
|
79
|
+
expect(result$).toBeObservable('#', {}, new Error('Name is required and must be a string'));
|
|
80
|
+
});
|
|
81
|
+
mtest('assertSchemaMap with valid input', ({ expect }) => {
|
|
82
|
+
const input$ = of({ name: 'John' });
|
|
83
|
+
const result$ = input$.pipe(assertSchemaMap(z.object({ name: z.string() }), 'Name is required and must be a string'), map((obj) => {
|
|
84
|
+
expectTypeOf().toEqualTypeOf();
|
|
85
|
+
return obj;
|
|
86
|
+
}));
|
|
87
|
+
expect(result$).toBeObservable('(a|)', { a: { name: 'John' } });
|
|
88
|
+
});
|
|
89
|
+
mtest('getTransformSet', ({ expect, coldStepAndClose }) => {
|
|
90
|
+
const setterArgument$ = new Subject();
|
|
91
|
+
const getter = () => coldStepAndClose(1);
|
|
92
|
+
const setter = (value) => {
|
|
93
|
+
setterArgument$.next(value);
|
|
94
|
+
return coldStepAndClose(undefined, 1);
|
|
95
|
+
};
|
|
96
|
+
const getTransformSet = createGetTransformSet(getter, setter);
|
|
97
|
+
const result$ = getTransformSet(map((x) => x + 1));
|
|
98
|
+
expect(result$).toBeObservableStepAndClose({ get: 1, set: 2 }, 2);
|
|
99
|
+
expect(setterArgument$).toBeObservableStep(2);
|
|
100
|
+
});
|
|
101
|
+
mtest('getTransformSet multiple operators', ({ expect, coldStepAndClose }) => {
|
|
102
|
+
const getter = () => coldStepAndClose(1);
|
|
103
|
+
const setter = (_) => {
|
|
104
|
+
return coldStepAndClose(undefined, 1);
|
|
105
|
+
};
|
|
106
|
+
const getTransformSet = createGetTransformSet(getter, setter);
|
|
107
|
+
const result$ = getTransformSet(map((x) => x + 1), map((x) => x * 2));
|
|
108
|
+
expect(result$).toBeObservableStepAndClose({ get: 1, set: 4 }, 2);
|
|
109
|
+
});
|
|
110
|
+
mtest('getTransformSetContext providing context', ({ expect, coldStepAndClose }) => {
|
|
111
|
+
const getter = () => coldStepAndClose(1);
|
|
112
|
+
const setter = (_) => {
|
|
113
|
+
return coldStepAndClose(undefined, 1);
|
|
114
|
+
};
|
|
115
|
+
const getTransformSet = createGetTransformSetContext(getter, setter);
|
|
116
|
+
const result$ = getTransformSet(map((x) => x + 1), map((x) => x * 2), map((x) => ({ set: x, context: 'hello' })));
|
|
117
|
+
expect(result$).toBeObservableStepAndClose({ get: 1, set: 4, context: 'hello' }, 2);
|
|
118
|
+
});
|
|
119
|
+
test('SyncFunctionToObservable<FUNC>', () => {
|
|
120
|
+
expectTypeOf().toEqualTypeOf();
|
|
121
|
+
});
|
|
122
|
+
mtest('getObservableMethodsFromSync', ({ expect }) => {
|
|
123
|
+
const service = {
|
|
124
|
+
addSync: (a, b) => a + b,
|
|
125
|
+
multiplySync: (a, b) => a * b,
|
|
126
|
+
};
|
|
127
|
+
const observableMethods = getObservableMethodsFromSync(service, ['add', 'multiply']);
|
|
128
|
+
expectTypeOf().toEqualTypeOf();
|
|
129
|
+
const add$ = observableMethods.add(2, 3);
|
|
130
|
+
expect(add$).toBeObservable('(5|)', { '5': 5 });
|
|
131
|
+
const multiply$ = observableMethods.multiply(2, 3);
|
|
132
|
+
expect(multiply$).toBeObservable('(6|)', { '6': 6 });
|
|
133
|
+
});
|
|
134
|
+
test('getObservableMethodsFromSync', () => {
|
|
135
|
+
const service = {
|
|
136
|
+
addSync: (a, b) => a + b,
|
|
137
|
+
};
|
|
138
|
+
expect(() => {
|
|
139
|
+
// @ts-expect-error multiplySync doesn't exist
|
|
140
|
+
getObservableMethodsFromSync(service, ['multiply']);
|
|
141
|
+
}).toThrow('Method "multiplySync" don\'t exists');
|
|
142
|
+
});
|
|
143
|
+
mtest('getObservableMethodsFromSync delay', ({ expect }) => {
|
|
144
|
+
const service = {
|
|
145
|
+
addSync: (a, b) => a + b,
|
|
146
|
+
};
|
|
147
|
+
const observableMethods = getObservableMethodsFromSync(service, ['add'], 1);
|
|
148
|
+
expectTypeOf().toEqualTypeOf();
|
|
149
|
+
const add$ = observableMethods.add(2, 3);
|
|
150
|
+
expect(add$).toBeObservable('-(5|)', { '5': 5 });
|
|
151
|
+
});
|
|
152
|
+
test('getUnsafeMethodNames', () => {
|
|
153
|
+
const service = {
|
|
154
|
+
safe: () => of(undefined),
|
|
155
|
+
unsafe: markUnsafeForMarbleTesting(() => of(undefined)),
|
|
156
|
+
};
|
|
157
|
+
const methodNames = getUnsafeMethodNames(service);
|
|
158
|
+
expect(methodNames).toEqual(['unsafe']);
|
|
159
|
+
expectTypeOf().toEqualTypeOf();
|
|
160
|
+
});
|