@thi.ng/interceptors 3.2.111 → 3.2.112
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/README.md +2 -2
- package/event-bus.js +12 -12
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 211 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -155,7 +155,7 @@ Browser ESM import:
|
|
|
155
155
|
|
|
156
156
|
[JSDelivr documentation](https://www.jsdelivr.com/)
|
|
157
157
|
|
|
158
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 2.
|
|
158
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 2.13 KB
|
|
159
159
|
|
|
160
160
|
## Dependencies
|
|
161
161
|
|
package/event-bus.js
CHANGED
|
@@ -168,7 +168,7 @@ class StatelessEventBus {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
addHandlers(specs) {
|
|
171
|
-
for (
|
|
171
|
+
for (const id in specs) {
|
|
172
172
|
this.addHandler(id, specs[id]);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -189,7 +189,7 @@ class StatelessEventBus {
|
|
|
189
189
|
priors.push(p);
|
|
190
190
|
}
|
|
191
191
|
addEffects(specs) {
|
|
192
|
-
for (
|
|
192
|
+
for (const id in specs) {
|
|
193
193
|
const fx = specs[id];
|
|
194
194
|
if (isArray(fx)) {
|
|
195
195
|
this.addEffect(id, fx[0], fx[1]);
|
|
@@ -209,7 +209,7 @@ class StatelessEventBus {
|
|
|
209
209
|
instrumentWith(inject, ids) {
|
|
210
210
|
const iceps = inject.map(__asInterceptor);
|
|
211
211
|
const handlers = this.handlers;
|
|
212
|
-
for (
|
|
212
|
+
for (const id of ids || Object.keys(handlers)) {
|
|
213
213
|
const h = handlers[id];
|
|
214
214
|
if (h) {
|
|
215
215
|
handlers[id] = iceps.concat(h);
|
|
@@ -220,7 +220,7 @@ class StatelessEventBus {
|
|
|
220
220
|
delete this.handlers[id];
|
|
221
221
|
}
|
|
222
222
|
removeHandlers(ids) {
|
|
223
|
-
for (
|
|
223
|
+
for (const id of ids) {
|
|
224
224
|
this.removeHandler(id);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
@@ -235,7 +235,7 @@ class StatelessEventBus {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
removeEffects(ids) {
|
|
238
|
-
for (
|
|
238
|
+
for (const id of ids) {
|
|
239
239
|
this.removeEffect(id);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -310,7 +310,7 @@ class StatelessEventBus {
|
|
|
310
310
|
this.currQueue = [...this.eventQueue];
|
|
311
311
|
this.eventQueue.length = 0;
|
|
312
312
|
ctx = this.currCtx = ctx || {};
|
|
313
|
-
for (
|
|
313
|
+
for (const e of this.currQueue) {
|
|
314
314
|
this.processEvent(ctx, e);
|
|
315
315
|
}
|
|
316
316
|
this.currQueue = this.currCtx = void 0;
|
|
@@ -384,7 +384,7 @@ class StatelessEventBus {
|
|
|
384
384
|
*/
|
|
385
385
|
processEffects(ctx) {
|
|
386
386
|
const effects = this.effects;
|
|
387
|
-
for (
|
|
387
|
+
for (const p of this.priorities) {
|
|
388
388
|
const id = p[0];
|
|
389
389
|
const val = ctx[id];
|
|
390
390
|
val !== void 0 && this.processEffect(ctx, effects, id, val);
|
|
@@ -393,7 +393,7 @@ class StatelessEventBus {
|
|
|
393
393
|
processEffect(ctx, effects, id, val) {
|
|
394
394
|
const fn = effects[id];
|
|
395
395
|
if (id !== FX_STATE) {
|
|
396
|
-
for (
|
|
396
|
+
for (const v of val) {
|
|
397
397
|
fn(v, this, ctx);
|
|
398
398
|
}
|
|
399
399
|
} else {
|
|
@@ -447,7 +447,7 @@ class StatelessEventBus {
|
|
|
447
447
|
if (!ret) {
|
|
448
448
|
return;
|
|
449
449
|
}
|
|
450
|
-
for (
|
|
450
|
+
for (const k in ret) {
|
|
451
451
|
const v = ret[k];
|
|
452
452
|
if (v == null) {
|
|
453
453
|
continue;
|
|
@@ -456,7 +456,7 @@ class StatelessEventBus {
|
|
|
456
456
|
ctx[k] = v;
|
|
457
457
|
} else if (k === FX_DISPATCH_NOW) {
|
|
458
458
|
if (isArray(v[0])) {
|
|
459
|
-
for (
|
|
459
|
+
for (const e of v) {
|
|
460
460
|
e && this.dispatchNow(e);
|
|
461
461
|
}
|
|
462
462
|
} else {
|
|
@@ -465,7 +465,7 @@ class StatelessEventBus {
|
|
|
465
465
|
} else {
|
|
466
466
|
ctx[k] || (ctx[k] = []);
|
|
467
467
|
if (isArray(v[0])) {
|
|
468
|
-
for (
|
|
468
|
+
for (const e of v) {
|
|
469
469
|
e !== void 0 && ctx[k].push(e);
|
|
470
470
|
}
|
|
471
471
|
} else {
|
|
@@ -637,7 +637,7 @@ class EventBus extends StatelessEventBus {
|
|
|
637
637
|
this.currQueue = [...this.eventQueue];
|
|
638
638
|
this.eventQueue.length = 0;
|
|
639
639
|
ctx = this.currCtx = { ...ctx, [FX_STATE]: prev };
|
|
640
|
-
for (
|
|
640
|
+
for (const e of this.currQueue) {
|
|
641
641
|
this.processEvent(ctx, e);
|
|
642
642
|
}
|
|
643
643
|
this.currQueue = this.currCtx = void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/interceptors",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.112",
|
|
4
4
|
"description": "Interceptor based event bus, side effect & immutable state handling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@thi.ng/api": "^8.12.
|
|
46
|
-
"@thi.ng/atom": "^5.3.
|
|
47
|
-
"@thi.ng/checks": "^3.
|
|
48
|
-
"@thi.ng/errors": "^2.5.
|
|
49
|
-
"@thi.ng/logger": "^3.2.
|
|
50
|
-
"@thi.ng/paths": "^5.2.
|
|
45
|
+
"@thi.ng/api": "^8.12.10",
|
|
46
|
+
"@thi.ng/atom": "^5.3.51",
|
|
47
|
+
"@thi.ng/checks": "^3.8.0",
|
|
48
|
+
"@thi.ng/errors": "^2.5.50",
|
|
49
|
+
"@thi.ng/logger": "^3.2.9",
|
|
50
|
+
"@thi.ng/paths": "^5.2.29"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"esbuild": "^0.27.0",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"status": "completed",
|
|
98
98
|
"year": 2016
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "824bf9047b5a10f777c5c5b4aeecf0c750a22c75\n"
|
|
101
101
|
}
|