@oscarpalmer/mora 0.35.0 → 0.36.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.
- package/dist/mora.full.mjs +24 -26
- package/package.json +3 -3
package/dist/mora.full.mjs
CHANGED
|
@@ -405,7 +405,6 @@ function lastIndexOf(array, ...parameters) {
|
|
|
405
405
|
return findValue(FIND_VALUE_INDEX, array, parameters, true);
|
|
406
406
|
}
|
|
407
407
|
indexOf.last = lastIndexOf;
|
|
408
|
-
Object.defineProperty(indexOf, "last", { value: lastIndexOf });
|
|
409
408
|
//#endregion
|
|
410
409
|
//#region node_modules/@oscarpalmer/atoms/dist/array/find.mjs
|
|
411
410
|
function find(array, ...parameters) {
|
|
@@ -415,7 +414,6 @@ function findLast(array, ...parameters) {
|
|
|
415
414
|
return findValue(FIND_VALUE_ITEM, array, parameters, true);
|
|
416
415
|
}
|
|
417
416
|
find.last = findLast;
|
|
418
|
-
Object.defineProperty(find, "last", { value: findLast });
|
|
419
417
|
//#endregion
|
|
420
418
|
//#region node_modules/@oscarpalmer/atoms/dist/array/select.mjs
|
|
421
419
|
function reverseSelect(array, ...parameters) {
|
|
@@ -434,7 +432,6 @@ function selectValues(array, parameters) {
|
|
|
434
432
|
}).matched;
|
|
435
433
|
}
|
|
436
434
|
select.reverse = reverseSelect;
|
|
437
|
-
Object.defineProperty(select, "reverse", { value: reverseSelect });
|
|
438
435
|
//#endregion
|
|
439
436
|
//#region node_modules/@oscarpalmer/atoms/dist/array/filter.mjs
|
|
440
437
|
function exclude(array, ...parameters) {
|
|
@@ -444,7 +441,6 @@ function filter(array, ...parameters) {
|
|
|
444
441
|
return findValues("all", array, parameters).matched;
|
|
445
442
|
}
|
|
446
443
|
filter.remove = exclude;
|
|
447
|
-
Object.defineProperty(filter, "remove", { value: exclude });
|
|
448
444
|
//#endregion
|
|
449
445
|
//#region src/helpers/misc.ts
|
|
450
446
|
function getState(value, options) {
|
|
@@ -454,7 +450,7 @@ function getState(value, options) {
|
|
|
454
450
|
};
|
|
455
451
|
}
|
|
456
452
|
//#endregion
|
|
457
|
-
//#region node_modules/@oscarpalmer/atoms/dist/internal/
|
|
453
|
+
//#region node_modules/@oscarpalmer/atoms/dist/internal/aborter.mjs
|
|
458
454
|
function createAborter(value, onAbort) {
|
|
459
455
|
if (!(value instanceof AbortSignal)) return;
|
|
460
456
|
value.addEventListener(ABORT_EVENT, onAbort, ABORT_OPTIONS);
|
|
@@ -472,40 +468,32 @@ const SUBSCRIPTION_NAME = "subscription";
|
|
|
472
468
|
const SUBSCRIPTION_PROPERTY = "$subscription";
|
|
473
469
|
const SUBSCRIPTION_STORE = "subscriptions";
|
|
474
470
|
function Subscription(state, property, parameters) {
|
|
475
|
-
|
|
471
|
+
this[SUBSCRIPTION_SYMBOL] = state;
|
|
472
|
+
this[property.key] = property.value;
|
|
476
473
|
state.aborter = createAborter(parameters.signal, () => this.unsubscribe(subscriptions, this, state));
|
|
477
|
-
Object.defineProperties(this, {
|
|
478
|
-
[property.key]: { value: property.value },
|
|
479
|
-
active: {
|
|
480
|
-
enumerable: true,
|
|
481
|
-
get: () => (state.parameters?.isActive?.() ?? true) && state.active
|
|
482
|
-
}
|
|
483
|
-
});
|
|
484
474
|
addSubscription(this);
|
|
485
475
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
476
|
+
Subscription.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_NAME;
|
|
477
|
+
Subscription.prototype.unsubscribe = removeSubscription;
|
|
478
|
+
Object.defineProperty(Subscription.prototype, "active", {
|
|
479
|
+
enumerable: true,
|
|
480
|
+
get: getSubscriptionActive
|
|
489
481
|
});
|
|
490
482
|
function Subscriptions(parameters) {
|
|
491
483
|
const { keys, property } = createSubscriptionsParameters(parameters);
|
|
492
|
-
|
|
484
|
+
this[SUBSCRIPTION_SYMBOL] = createSubscriptionsState(property, keys);
|
|
493
485
|
}
|
|
486
|
+
Subscriptions.prototype[SUBSCRIPTION_PROPERTY] = SUBSCRIPTION_STORE;
|
|
487
|
+
Subscriptions.prototype.clear = clearSubscriptions;
|
|
488
|
+
Subscriptions.prototype.create = createSubscription;
|
|
494
489
|
Object.defineProperties(Subscriptions.prototype, {
|
|
495
|
-
[SUBSCRIPTION_PROPERTY]: { value: SUBSCRIPTION_STORE },
|
|
496
|
-
clear: { value: clearSubscriptions },
|
|
497
|
-
create: { value: createSubscription },
|
|
498
490
|
items: {
|
|
499
491
|
enumerable: true,
|
|
500
|
-
get
|
|
501
|
-
return this[SUBSCRIPTION_SYMBOL].items;
|
|
502
|
-
}
|
|
492
|
+
get: getSubscriptionsItems
|
|
503
493
|
},
|
|
504
494
|
values: {
|
|
505
495
|
enumerable: true,
|
|
506
|
-
get
|
|
507
|
-
return this[SUBSCRIPTION_SYMBOL].values;
|
|
508
|
-
}
|
|
496
|
+
get: getSubscriptionsValues
|
|
509
497
|
}
|
|
510
498
|
});
|
|
511
499
|
function addSubscription(instance) {
|
|
@@ -568,6 +556,16 @@ function getExistingSubscription(subscriptions, state) {
|
|
|
568
556
|
const { parameters } = state;
|
|
569
557
|
return isKey(parameters.key) ? values.from.keyed?.get(parameters.key)?.get(parameters.value) : values.from.any.get(parameters.value);
|
|
570
558
|
}
|
|
559
|
+
function getSubscriptionActive() {
|
|
560
|
+
const state = this[SUBSCRIPTION_SYMBOL];
|
|
561
|
+
return (state.parameters?.isActive?.() ?? true) && state.active;
|
|
562
|
+
}
|
|
563
|
+
function getSubscriptionsItems() {
|
|
564
|
+
return this[SUBSCRIPTION_SYMBOL].items;
|
|
565
|
+
}
|
|
566
|
+
function getSubscriptionsValues() {
|
|
567
|
+
return this[SUBSCRIPTION_SYMBOL].values;
|
|
568
|
+
}
|
|
571
569
|
function createSubscriptionParameters(input) {
|
|
572
570
|
const values = isPlainObject(input) ? input : {};
|
|
573
571
|
if (values.value == null) throw new Error(SUBSCRIPTION_INVALID_VALUE);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oscarpalmer/mora",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Signals and stuff…",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"reactive",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"test:leak": "vpx vp test run --detect-async-leaks --coverage"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@oscarpalmer/atoms": "^0.
|
|
42
|
+
"@oscarpalmer/atoms": "^0.204"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^26.5",
|
|
46
46
|
"@vitest/coverage-istanbul": "^4.1",
|
|
47
|
-
"jsdom": "^30",
|
|
47
|
+
"jsdom": "^30.1",
|
|
48
48
|
"tsdown": "^0.23",
|
|
49
49
|
"typescript": "^6",
|
|
50
50
|
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|