@limitlesspc/konbini 1.0.0 → 1.0.2
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/index.cjs +8 -11
- package/dist/index.js +8 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24,14 +24,13 @@ __export(index_exports, {
|
|
|
24
24
|
konbini: () => konbini
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
var
|
|
27
|
+
var outerCompute;
|
|
28
28
|
function konbini(value) {
|
|
29
|
-
const subscribers =
|
|
29
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
30
30
|
const store = (...args) => {
|
|
31
31
|
if (!args.length) {
|
|
32
|
-
const outerCompute = computationStack.at(-1);
|
|
33
32
|
if (outerCompute) {
|
|
34
|
-
subscribers.
|
|
33
|
+
subscribers.add(outerCompute);
|
|
35
34
|
}
|
|
36
35
|
return value;
|
|
37
36
|
}
|
|
@@ -47,12 +46,9 @@ function konbini(value) {
|
|
|
47
46
|
store.set = (newValue) => store(newValue);
|
|
48
47
|
store.subscribe = (subscriber) => {
|
|
49
48
|
subscriber(value);
|
|
50
|
-
subscribers.
|
|
49
|
+
subscribers.add(subscriber);
|
|
51
50
|
return () => {
|
|
52
|
-
|
|
53
|
-
if (index !== -1) {
|
|
54
|
-
subscribers.splice(index, 1);
|
|
55
|
-
}
|
|
51
|
+
subscribers.delete(subscriber);
|
|
56
52
|
};
|
|
57
53
|
};
|
|
58
54
|
return store;
|
|
@@ -63,9 +59,10 @@ function computed(fn) {
|
|
|
63
59
|
const result = fn();
|
|
64
60
|
store(result);
|
|
65
61
|
}
|
|
66
|
-
|
|
62
|
+
const prevOuterCompute = outerCompute;
|
|
63
|
+
outerCompute = compute;
|
|
67
64
|
compute();
|
|
68
|
-
|
|
65
|
+
outerCompute = prevOuterCompute;
|
|
69
66
|
return store;
|
|
70
67
|
}
|
|
71
68
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// index.ts
|
|
2
|
-
var
|
|
2
|
+
var outerCompute;
|
|
3
3
|
function konbini(value) {
|
|
4
|
-
const subscribers =
|
|
4
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
5
5
|
const store = (...args) => {
|
|
6
6
|
if (!args.length) {
|
|
7
|
-
const outerCompute = computationStack.at(-1);
|
|
8
7
|
if (outerCompute) {
|
|
9
|
-
subscribers.
|
|
8
|
+
subscribers.add(outerCompute);
|
|
10
9
|
}
|
|
11
10
|
return value;
|
|
12
11
|
}
|
|
@@ -22,12 +21,9 @@ function konbini(value) {
|
|
|
22
21
|
store.set = (newValue) => store(newValue);
|
|
23
22
|
store.subscribe = (subscriber) => {
|
|
24
23
|
subscriber(value);
|
|
25
|
-
subscribers.
|
|
24
|
+
subscribers.add(subscriber);
|
|
26
25
|
return () => {
|
|
27
|
-
|
|
28
|
-
if (index !== -1) {
|
|
29
|
-
subscribers.splice(index, 1);
|
|
30
|
-
}
|
|
26
|
+
subscribers.delete(subscriber);
|
|
31
27
|
};
|
|
32
28
|
};
|
|
33
29
|
return store;
|
|
@@ -38,9 +34,10 @@ function computed(fn) {
|
|
|
38
34
|
const result = fn();
|
|
39
35
|
store(result);
|
|
40
36
|
}
|
|
41
|
-
|
|
37
|
+
const prevOuterCompute = outerCompute;
|
|
38
|
+
outerCompute = compute;
|
|
42
39
|
compute();
|
|
43
|
-
|
|
40
|
+
outerCompute = prevOuterCompute;
|
|
44
41
|
return store;
|
|
45
42
|
}
|
|
46
43
|
export {
|