atomaric 0.0.69 → 0.0.70
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/build/atomaric.js +173 -136
- package/build/atomaric.umd.cjs +1 -1
- package/package.json +1 -1
- package/src/do.classes/Map.test.ts +71 -0
- package/src/do.classes/Map.ts +42 -0
- package/src/do.classes/Object.test.ts +13 -3
- package/types/index.d.ts +3 -0
package/build/atomaric.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
let k = () => {
|
|
2
2
|
throw "call configureAtomaric() before all!";
|
|
3
3
|
};
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
}, ne = (t) => k(t.subscribe, t.get), oe = (t) => t.set,
|
|
7
|
-
class
|
|
4
|
+
const M = {}, Se = (t) => {
|
|
5
|
+
M.useSyncExternalStore = k = t.useSyncExternalStore, M.keyPathSeparator = t.keyPathSeparator, M.securifyKeyLevel = t.securifyKeyLevel, M.securifyValueLevel = t.securifyValueLevel;
|
|
6
|
+
}, ne = (t) => k(t.subscribe, t.get), oe = (t) => t.set, xe = (t) => t.setDeferred, be = (t) => t.get, De = (t) => t.do, $e = (t) => [ne(t), oe(t)], Me = (t, e) => new pe(t, e);
|
|
7
|
+
class _ {
|
|
8
8
|
constructor(e) {
|
|
9
9
|
if (e)
|
|
10
10
|
return new Proxy(this, {
|
|
@@ -14,33 +14,33 @@ class E {
|
|
|
14
14
|
}
|
|
15
15
|
const ce = (t, e) => {
|
|
16
16
|
const n = (s, o, i) => new Proxy(s, {
|
|
17
|
-
get: (
|
|
18
|
-
const d = i === 0 && e.get != null ? e.get(
|
|
17
|
+
get: (l, h, p) => {
|
|
18
|
+
const d = i === 0 && e.get != null ? e.get(l, h, p) : l[h];
|
|
19
19
|
return typeof d == "object" && d !== null ? n(
|
|
20
20
|
Array.isArray(d) ? d.slice(0) : { ...d },
|
|
21
|
-
o.concat(Array.isArray(
|
|
21
|
+
o.concat(Array.isArray(l) ? +h : h),
|
|
22
22
|
i + 1
|
|
23
23
|
) : d;
|
|
24
24
|
},
|
|
25
|
-
set: (
|
|
25
|
+
set: (l, h, p) => (e.onSet(l, o, h, p, l[h]) && (l[h] = p), !0)
|
|
26
26
|
});
|
|
27
27
|
return n(t, [], 0);
|
|
28
28
|
};
|
|
29
|
-
class O extends
|
|
29
|
+
class O extends _ {
|
|
30
30
|
constructor() {
|
|
31
31
|
super(...arguments), this.updateValue = (e, n) => {
|
|
32
32
|
const s = Array.isArray(e) ? e.slice(0) : { ...e };
|
|
33
33
|
let o = !1;
|
|
34
34
|
const i = ce(e, {
|
|
35
|
-
onSet: (
|
|
36
|
-
if (d ===
|
|
37
|
-
let
|
|
35
|
+
onSet: (l, h, p, d, y) => {
|
|
36
|
+
if (d === y) return !0;
|
|
37
|
+
let S = s;
|
|
38
38
|
o = !0;
|
|
39
|
-
for (const
|
|
40
|
-
const
|
|
41
|
-
|
|
39
|
+
for (const f of h) {
|
|
40
|
+
const m = S[f];
|
|
41
|
+
S = S[f] = Array.isArray(m) ? m.slice(0) : { ...m };
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return S[p] = d, !0;
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
return n(i), o ? s : e;
|
|
@@ -66,27 +66,43 @@ class ie extends O {
|
|
|
66
66
|
const i = this.atom.get().slice(0);
|
|
67
67
|
i.splice(o, 1), this.atom.set(i);
|
|
68
68
|
}, this.toggle = (s, o) => {
|
|
69
|
-
const i = this.atom.get().slice(),
|
|
70
|
-
|
|
69
|
+
const i = this.atom.get().slice(), l = i.indexOf(s);
|
|
70
|
+
l < 0 ? o ? i.unshift(s) : i.push(s) : i.splice(l, 1), this.atom.set(i);
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
const ae = (t) => t;
|
|
75
|
-
class ue extends
|
|
75
|
+
class ue extends _ {
|
|
76
76
|
constructor(e, n) {
|
|
77
77
|
super(n), this.atom = e, this.toggle = () => {
|
|
78
78
|
this.atom.set(!this.atom.get());
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
class le extends
|
|
82
|
+
class le extends _ {
|
|
83
|
+
constructor(e, n) {
|
|
84
|
+
super(n), this.atom = e, this.setValue = (s, o) => {
|
|
85
|
+
const i = new Map(this.atom.get());
|
|
86
|
+
i.set(s, o), this.atom.set(i);
|
|
87
|
+
}, this.delete = (s) => {
|
|
88
|
+
const o = new Map(this.atom.get());
|
|
89
|
+
o.delete(s), this.atom.set(o);
|
|
90
|
+
}, this.toggle = (s, o) => {
|
|
91
|
+
const i = new Map(this.atom.get());
|
|
92
|
+
i.has(s) ? i.delete(s) : i.set(s, o), this.atom.set(i);
|
|
93
|
+
}, this.clear = () => {
|
|
94
|
+
this.atom.set(/* @__PURE__ */ new Map());
|
|
95
|
+
}, this.atom = e;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
class fe extends _ {
|
|
83
99
|
constructor(e, n) {
|
|
84
100
|
super(n), this.atom = e, this.increment = (s) => {
|
|
85
101
|
this.atom.set(+this.atom.get() + (s ?? 1));
|
|
86
102
|
};
|
|
87
103
|
}
|
|
88
104
|
}
|
|
89
|
-
class
|
|
105
|
+
class he extends O {
|
|
90
106
|
constructor(e, n) {
|
|
91
107
|
super(n), this.atom = e, this.setPartial = (s) => this.atom.set((o) => ({
|
|
92
108
|
...o,
|
|
@@ -94,36 +110,36 @@ class fe extends O {
|
|
|
94
110
|
})), this.update = (s) => {
|
|
95
111
|
const o = this.atom.get(), i = this.updateValue(o, s);
|
|
96
112
|
i !== o && this.atom.set(i);
|
|
97
|
-
}, this.setDeepPartial = (s, o, i,
|
|
98
|
-
if (!
|
|
99
|
-
if (s.includes(
|
|
100
|
-
let d = s.split(
|
|
101
|
-
const
|
|
113
|
+
}, this.setDeepPartial = (s, o, i, l = M.keyPathSeparator || ".") => {
|
|
114
|
+
if (!l) return;
|
|
115
|
+
if (s.includes(l)) {
|
|
116
|
+
let d = s.split(l);
|
|
117
|
+
const y = d[d.length - 1];
|
|
102
118
|
d = d.slice(0, -1);
|
|
103
|
-
const
|
|
104
|
-
let
|
|
105
|
-
for (const
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
119
|
+
const S = { ...this.atom.get() };
|
|
120
|
+
let f = S, m = i;
|
|
121
|
+
for (const w of d) {
|
|
122
|
+
m = m == null ? void 0 : m[Array.isArray(m) ? "0" : w];
|
|
123
|
+
const D = f[Z(f, w)] ?? (Array.isArray(m) ? [] : {});
|
|
124
|
+
if (D == null || typeof D != "object") {
|
|
109
125
|
if (i == null) throw "Incorrect path for setDeepPartial";
|
|
110
|
-
const
|
|
111
|
-
this.atom.get()[s] !==
|
|
126
|
+
const b = typeof o == "function" ? o(void 0) : o;
|
|
127
|
+
this.atom.get()[s] !== b && this.setPartial({ [s]: b });
|
|
112
128
|
return;
|
|
113
129
|
}
|
|
114
|
-
|
|
130
|
+
f = f[Z(f, w)] = Array.isArray(D) ? [...D] : { ...D };
|
|
115
131
|
}
|
|
116
|
-
const
|
|
117
|
-
|
|
132
|
+
const E = f[y];
|
|
133
|
+
f[y] = typeof o == "function" ? o(f[y]) : o, E !== f[y] && this.atom.set(S);
|
|
118
134
|
return;
|
|
119
135
|
}
|
|
120
|
-
const
|
|
121
|
-
|
|
136
|
+
const h = this.atom.get()[s], p = typeof o == "function" ? o(h) : o;
|
|
137
|
+
p !== h && this.setPartial({ [s]: p });
|
|
122
138
|
};
|
|
123
139
|
}
|
|
124
140
|
}
|
|
125
141
|
const Z = (t, e) => Array.isArray(t) ? `${+e}` : e;
|
|
126
|
-
class
|
|
142
|
+
class me extends _ {
|
|
127
143
|
constructor(e, n) {
|
|
128
144
|
super(n), this.atom = e, this.add = (s) => {
|
|
129
145
|
this.atom.set(new Set(this.atom.get()).add(s));
|
|
@@ -138,168 +154,188 @@ class he extends E {
|
|
|
138
154
|
}, this.atom = e;
|
|
139
155
|
}
|
|
140
156
|
}
|
|
141
|
-
const
|
|
157
|
+
const de = (t, e, n) => {
|
|
142
158
|
const s = typeof n == "object" && n != null && "do" in n ? n.do(
|
|
143
|
-
(i,
|
|
159
|
+
(i, l) => e.set(i, l),
|
|
144
160
|
() => e.get(),
|
|
145
161
|
e,
|
|
146
|
-
(i,
|
|
162
|
+
(i, l, h) => e.setDeferred(i, l, h)
|
|
147
163
|
) : null, o = {};
|
|
148
|
-
return s && Object.keys(s).forEach((i) => Object.defineProperty(o, i, { get: () => s[i] })), typeof t == "number" ? new
|
|
164
|
+
return s && Object.keys(s).forEach((i) => Object.defineProperty(o, i, { get: () => s[i] })), typeof t == "number" ? new fe(e, s) : typeof t == "boolean" ? new ue(e, s) : Array.isArray(t) ? new ie(e, s) : t instanceof Set ? new me(e, s) : t instanceof Map ? new le(e, s) : t instanceof Object ? new he(e, s) : new _(s);
|
|
149
165
|
};
|
|
150
|
-
class
|
|
166
|
+
class pe {
|
|
151
167
|
constructor(e, n) {
|
|
152
168
|
e = typeof e == "function" ? e() : e;
|
|
153
|
-
const s = (r) => d = r, o = () => d, i = /* @__PURE__ */ new Set(),
|
|
154
|
-
let
|
|
155
|
-
},
|
|
156
|
-
const r =
|
|
157
|
-
return
|
|
169
|
+
const s = (r) => d = r, o = () => d, i = /* @__PURE__ */ new Set(), l = (r) => r(f());
|
|
170
|
+
let h = !0, p = !1, d = e, y, S = () => {
|
|
171
|
+
}, f = () => o(), m = null, E = () => {
|
|
172
|
+
const r = de(e, w, n);
|
|
173
|
+
return E = () => r, r;
|
|
158
174
|
};
|
|
159
|
-
const
|
|
160
|
-
get: (r,
|
|
161
|
-
set:
|
|
162
|
-
}),
|
|
163
|
-
|
|
175
|
+
const w = new Proxy(this, {
|
|
176
|
+
get: (r, a) => a === "do" ? E() : r[a],
|
|
177
|
+
set: ge
|
|
178
|
+
}), D = () => {
|
|
179
|
+
h = !0, p !== !0 && S(f()), p = !1;
|
|
164
180
|
try {
|
|
165
|
-
|
|
181
|
+
v.postMessage({ key: u, value: o() });
|
|
166
182
|
} catch {
|
|
167
183
|
}
|
|
168
|
-
},
|
|
169
|
-
const
|
|
170
|
-
|
|
184
|
+
}, b = (r, a) => {
|
|
185
|
+
const g = typeof r == "function" ? r(f()) : r;
|
|
186
|
+
g !== f() && (s(g), p = a, h && (h = !1, i.forEach(l), queueMicrotask(D)));
|
|
171
187
|
};
|
|
172
|
-
this.set = (r,
|
|
188
|
+
this.set = (r, a) => b(r, a), this.get = () => f(), this.initialValue = e, this.isInitialValue = () => e === o(), this.subscribe = (r) => (i.add(r), () => {
|
|
173
189
|
i.delete(r);
|
|
174
190
|
}), this.reset = () => {
|
|
175
|
-
|
|
191
|
+
b(e, !0);
|
|
176
192
|
};
|
|
177
|
-
const re = (r,
|
|
178
|
-
|
|
193
|
+
const re = (r, a) => {
|
|
194
|
+
b(r, a), y = void 0;
|
|
179
195
|
};
|
|
180
|
-
if (this.setDeferred = (r,
|
|
181
|
-
|
|
182
|
-
}, n == null) return
|
|
183
|
-
let
|
|
196
|
+
if (this.setDeferred = (r, a = 500, g, x = !0) => {
|
|
197
|
+
x && y === void 0 && b(r, g), clearTimeout(y), y = setTimeout(re, a, r, g);
|
|
198
|
+
}, n == null) return w;
|
|
199
|
+
let A = null, V = null, U = !0, q = !0, J = !1, $ = 0, T = 0, K = -1, L = e instanceof Set ? (r) => new Set(r) : e instanceof Map ? (r) => {
|
|
200
|
+
if (!r || typeof r != "object") return /* @__PURE__ */ new Map();
|
|
201
|
+
const a = /* @__PURE__ */ new Map();
|
|
202
|
+
for (const g in r)
|
|
203
|
+
try {
|
|
204
|
+
a.set(JSON.parse(g), r[g]);
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
return a;
|
|
208
|
+
} : (r) => r, j = e instanceof Set ? (r) => {
|
|
184
209
|
if (r instanceof Set) return Array.from(r);
|
|
185
210
|
throw console.error(r), "The value is not Set instance";
|
|
211
|
+
} : e instanceof Map ? (r) => {
|
|
212
|
+
if (r instanceof Map) {
|
|
213
|
+
const a = {};
|
|
214
|
+
return r.forEach((g, x) => {
|
|
215
|
+
try {
|
|
216
|
+
a[JSON.stringify(x)] = g;
|
|
217
|
+
} catch {
|
|
218
|
+
}
|
|
219
|
+
}), a;
|
|
220
|
+
}
|
|
221
|
+
throw console.error(r), "The value is not Set instance";
|
|
186
222
|
} : (r) => r;
|
|
187
223
|
if (typeof n == "string")
|
|
188
|
-
|
|
224
|
+
A = n;
|
|
189
225
|
else if ("storeKey" in n)
|
|
190
|
-
|
|
191
|
-
else return
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
194
|
-
const r = `${
|
|
195
|
-
r in c && (c[
|
|
226
|
+
U = n.warnOnDuplicateStoreKey ?? U, q = n.listenStorageChanges ?? q, A = n.storeKey, L = n.unzipValue ?? L, j = n.zipValue ?? j, J = n.unchangable ?? J, $ = n.securifyKeyLevel ?? M.securifyKeyLevel ?? $, T = n.securifyValueLevel ?? M.securifyValueLevel ?? T, V = n.exp ?? V;
|
|
227
|
+
else return w;
|
|
228
|
+
const B = $ ? C(A, $) : A, u = `${T ? H : I}${B}`;
|
|
229
|
+
if ($) {
|
|
230
|
+
const r = `${I}${A}`;
|
|
231
|
+
r in c && (c[u] = c[r], delete c[r]);
|
|
196
232
|
} else {
|
|
197
|
-
const r = `${
|
|
198
|
-
r in c && (c[
|
|
233
|
+
const r = `${I}${C(A, $)}`;
|
|
234
|
+
r in c && (c[u] = c[r], delete c[r]);
|
|
199
235
|
}
|
|
200
|
-
const
|
|
236
|
+
const F = V === null || !(V(w, u in c) instanceof Date) ? (r) => C([j(r)], 0) : (r) => (m ?? (m = {}), m.exp = V(w, u in c).getTime(), m.exp - Date.now() < 24 * 60 * 60 * 1e3 && (clearTimeout(K), clearTimeout(ee[u]), K = setTimeout(() => this.reset(), m.exp - Date.now())), m.exp = Math.trunc(m.exp / 1e3), C([j(r), m], 0));
|
|
201
237
|
if (T) {
|
|
202
|
-
const r = `${
|
|
203
|
-
if (
|
|
238
|
+
const r = `${I}${B}`, a = j, g = L;
|
|
239
|
+
if (j = (x) => {
|
|
204
240
|
try {
|
|
205
|
-
return
|
|
241
|
+
return C([a(x)], T);
|
|
206
242
|
} catch {
|
|
207
|
-
return delete c[
|
|
243
|
+
return delete c[u], "";
|
|
208
244
|
}
|
|
209
245
|
}, r in c) {
|
|
210
|
-
const
|
|
246
|
+
const x = `${I}${C(A, $)}`;
|
|
211
247
|
try {
|
|
212
|
-
c[
|
|
248
|
+
c[x] = F(L(z(c[r], 0)[0])), delete c[r];
|
|
213
249
|
} catch {
|
|
214
250
|
}
|
|
215
251
|
}
|
|
216
|
-
|
|
252
|
+
L = (x) => {
|
|
217
253
|
try {
|
|
218
|
-
return
|
|
254
|
+
return g(z(x, T)[0]);
|
|
219
255
|
} catch {
|
|
220
|
-
return delete c[
|
|
256
|
+
return delete c[u], "";
|
|
221
257
|
}
|
|
222
258
|
};
|
|
223
|
-
} else delete c[`${H}${
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
return
|
|
259
|
+
} else delete c[`${H}${B}`];
|
|
260
|
+
const X = (r) => {
|
|
261
|
+
const a = z(r, 0);
|
|
262
|
+
return m = a[1], L(a[0]);
|
|
227
263
|
};
|
|
228
|
-
let
|
|
229
|
-
if (
|
|
230
|
-
if (
|
|
231
|
-
|
|
264
|
+
let Y = !0;
|
|
265
|
+
if (G[u] = w, c[`atom/${A}`] && (c[u] || (c[u] = `[${c[`atom/${A}`]}]`), delete c[`atom/${A}`]), f = () => {
|
|
266
|
+
if (f = o, Y) {
|
|
267
|
+
Y = !1;
|
|
232
268
|
try {
|
|
233
|
-
s(
|
|
269
|
+
s(u in c ? X(c[u]) : e);
|
|
234
270
|
} catch {
|
|
235
|
-
console.warn("Invalid json value", c[
|
|
271
|
+
console.warn("Invalid json value", c[u]);
|
|
236
272
|
}
|
|
237
273
|
}
|
|
238
274
|
return o();
|
|
239
|
-
},
|
|
275
|
+
}, S = (r) => {
|
|
240
276
|
if (r === e) {
|
|
241
277
|
this.reset();
|
|
242
278
|
return;
|
|
243
279
|
}
|
|
244
|
-
c[
|
|
280
|
+
c[u] = F(r);
|
|
245
281
|
}, this.reset = () => {
|
|
246
|
-
delete c[
|
|
247
|
-
},
|
|
248
|
-
if (
|
|
249
|
-
let r = !1,
|
|
250
|
-
|
|
251
|
-
clearTimeout(
|
|
282
|
+
delete c[u], b(e, !0);
|
|
283
|
+
}, U && P[u] !== void 0 && console.warn("Duplicate Atom key", A), q)
|
|
284
|
+
if (J) {
|
|
285
|
+
let r = !1, a;
|
|
286
|
+
N[u] = this, P[u] = () => {
|
|
287
|
+
clearTimeout(a), a = setTimeout(() => r = !1, 10), !r && (r = !0, c[u] = F(o()));
|
|
252
288
|
};
|
|
253
289
|
} else
|
|
254
|
-
|
|
290
|
+
P[u] = (r) => {
|
|
255
291
|
if (r.newValue === null) {
|
|
256
292
|
this.reset();
|
|
257
293
|
return;
|
|
258
294
|
}
|
|
259
295
|
try {
|
|
260
|
-
|
|
296
|
+
b(X(r.newValue));
|
|
261
297
|
} catch {
|
|
262
298
|
console.warn("Invalid json value", r.newValue);
|
|
263
299
|
}
|
|
264
300
|
};
|
|
265
|
-
return
|
|
301
|
+
return w;
|
|
266
302
|
}
|
|
267
303
|
}
|
|
268
|
-
let
|
|
304
|
+
let v;
|
|
269
305
|
try {
|
|
270
|
-
|
|
306
|
+
v = new BroadcastChannel("updateHere"), v.addEventListener("message", (t) => {
|
|
271
307
|
var e;
|
|
272
|
-
(e =
|
|
308
|
+
(e = N[t.data.key]) == null || e.set(t.data.value, !0);
|
|
273
309
|
});
|
|
274
310
|
} catch {
|
|
275
311
|
}
|
|
276
|
-
const c = localStorage,
|
|
312
|
+
const c = localStorage, P = {}, N = {}, ge = (t, e) => {
|
|
277
313
|
throw `${e} is readonly property`;
|
|
278
314
|
};
|
|
279
315
|
window.addEventListener("storage", (t) => {
|
|
280
316
|
var e;
|
|
281
|
-
t.key === null || t.newValue === t.oldValue || (e =
|
|
317
|
+
t.key === null || t.newValue === t.oldValue || (e = P[t.key]) == null || e.call(P, t);
|
|
282
318
|
});
|
|
283
|
-
const
|
|
319
|
+
const ye = c.setItem.bind(c), we = c.removeItem.bind(c);
|
|
284
320
|
c.setItem = (t, e) => {
|
|
285
|
-
|
|
321
|
+
N[t] === void 0 && ye.call(c, t, e);
|
|
286
322
|
};
|
|
287
323
|
c.removeItem = (t) => {
|
|
288
|
-
|
|
324
|
+
N[t] === void 0 && we.call(c, t);
|
|
289
325
|
};
|
|
290
|
-
const
|
|
326
|
+
const Ae = /"exp":\s*(\d+)/, I = "atom\\", H = "atom`s\\", G = {}, ee = {}, te = /[a-z]/gi, R = 5, Q = {};
|
|
291
327
|
for (let t = 54; t < 80; t++) {
|
|
292
328
|
if (t === 68 || t === 72 || t === 55) continue;
|
|
293
329
|
const e = String.fromCharCode(t + 43).toUpperCase(), n = String.fromCharCode(t + 43).toLowerCase();
|
|
294
|
-
|
|
330
|
+
Q[e] = n, Q[n] = e;
|
|
295
331
|
}
|
|
296
|
-
const se = (t) =>
|
|
332
|
+
const se = (t) => Q[t] ?? t, C = /* @__PURE__ */ (() => {
|
|
297
333
|
const t = [
|
|
298
334
|
(e) => JSON.stringify(e),
|
|
299
335
|
(e) => btoa(encodeURI(t[0](e))),
|
|
300
336
|
(e) => {
|
|
301
337
|
const n = t[1](e);
|
|
302
|
-
return `${n.slice(0,
|
|
338
|
+
return `${n.slice(0, R)}${n.slice(R).replace(te, se)}`;
|
|
303
339
|
},
|
|
304
340
|
(e) => btoa(t[2](e))
|
|
305
341
|
];
|
|
@@ -311,12 +347,12 @@ const se = (t) => G[t] ?? t, I = /* @__PURE__ */ (() => {
|
|
|
311
347
|
return t[0](e);
|
|
312
348
|
}
|
|
313
349
|
};
|
|
314
|
-
})(),
|
|
350
|
+
})(), z = /* @__PURE__ */ (() => {
|
|
315
351
|
const t = [
|
|
316
352
|
(e) => JSON.parse(e),
|
|
317
353
|
(e) => t[0](decodeURI(atob(e))),
|
|
318
354
|
(e) => t[1](
|
|
319
|
-
`${e.slice(0,
|
|
355
|
+
`${e.slice(0, R)}${e.slice(R).replace(te, se)}`
|
|
320
356
|
),
|
|
321
357
|
(e) => t[2](atob(e))
|
|
322
358
|
];
|
|
@@ -332,29 +368,30 @@ const se = (t) => G[t] ?? t, I = /* @__PURE__ */ (() => {
|
|
|
332
368
|
setTimeout(() => {
|
|
333
369
|
Object.keys(c).forEach((t) => {
|
|
334
370
|
var s;
|
|
335
|
-
if (typeof c[t] != "string" || !t.startsWith(
|
|
336
|
-
const e = +((s = c[t].match(
|
|
371
|
+
if (typeof c[t] != "string" || !t.startsWith(I) && !t.startsWith(H)) return;
|
|
372
|
+
const e = +((s = c[t].match(Ae)) == null ? void 0 : s[1]);
|
|
337
373
|
if (!e || e * 1e3 - Date.now() > 24 * 60 * 60 * 1e3) return;
|
|
338
|
-
const n =
|
|
374
|
+
const n = z(c[t], 0);
|
|
339
375
|
!Array.isArray(n) || n[1] == null || !("exp" in n[1]) || n[1].exp !== e || (ee[t] = setTimeout(() => {
|
|
340
|
-
|
|
376
|
+
G[t] ? G[t].reset() : delete c[t];
|
|
341
377
|
}, e * 1e3 - Date.now()));
|
|
342
378
|
});
|
|
343
379
|
}, 1e3);
|
|
344
380
|
export {
|
|
345
|
-
|
|
381
|
+
pe as Atom,
|
|
346
382
|
ie as AtomArrayDoActions,
|
|
347
383
|
ue as AtomBooleanDoActions,
|
|
348
|
-
le as
|
|
349
|
-
fe as
|
|
350
|
-
he as
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
384
|
+
le as AtomMapDoActions,
|
|
385
|
+
fe as AtomNumberDoActions,
|
|
386
|
+
he as AtomObjectDoActions,
|
|
387
|
+
me as AtomSetDoActions,
|
|
388
|
+
Me as atom,
|
|
389
|
+
Se as configureAtomaric,
|
|
390
|
+
M as configuredOptions,
|
|
391
|
+
$e as useAtom,
|
|
392
|
+
De as useAtomDo,
|
|
393
|
+
be as useAtomGet,
|
|
357
394
|
oe as useAtomSet,
|
|
358
|
-
|
|
395
|
+
xe as useAtomSetDeferred,
|
|
359
396
|
ne as useAtomValue
|
|
360
397
|
};
|
package/build/atomaric.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(l=typeof globalThis<"u"?globalThis:l||self,j(l.atomaric={}))})(this,function(l){"use strict";let j=()=>{throw"call configureAtomaric() before all!"};const
|
|
1
|
+
(function(l,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(l=typeof globalThis<"u"?globalThis:l||self,j(l.atomaric={}))})(this,function(l){"use strict";let j=()=>{throw"call configureAtomaric() before all!"};const $={},me=t=>{$.useSyncExternalStore=j=t.useSyncExternalStore,$.keyPathSeparator=t.keyPathSeparator,$.securifyKeyLevel=t.securifyKeyLevel,$.securifyValueLevel=t.securifyValueLevel},Y=t=>j(t.subscribe,t.get),Z=t=>t.set,de=t=>t.setDeferred,Ae=t=>t.get,ge=t=>t.do,ye=t=>[Y(t),Z(t)],pe=(t,e)=>new ce(t,e);class L{constructor(e){if(e)return new Proxy(this,{get:(r,s)=>s in this?r[s]:e[s]})}}const we=(t,e)=>{const r=(s,o,i)=>new Proxy(s,{get:(f,m,g)=>{const A=i===0&&e.get!=null?e.get(f,m,g):f[m];return typeof A=="object"&&A!==null?r(Array.isArray(A)?A.slice(0):{...A},o.concat(Array.isArray(f)?+m:m),i+1):A},set:(f,m,g)=>(e.onSet(f,o,m,g,f[m])&&(f[m]=g),!0)});return r(t,[],0)};class k extends L{constructor(){super(...arguments),this.updateValue=(e,r)=>{const s=Array.isArray(e)?e.slice(0):{...e};let o=!1;const i=we(e,{onSet:(f,m,g,A,p)=>{if(A===p)return!0;let b=s;o=!0;for(const h of m){const d=b[h];b=b[h]=Array.isArray(d)?d.slice(0):{...d}}return b[g]=A,!0}});return r(i),o?s:e}}}class O extends k{constructor(e,r){super(r),this.atom=e,this.push=(...s)=>{this.atom.set(this.atom.get().concat(s))},this.unshift=(...s)=>{this.atom.set(s.concat(this.atom.get()))},this.update=s=>{const o=this.atom.get(),i=this.updateValue(o,s);i!==o&&this.atom.set(i)},this.filter=s=>{this.atom.set(this.atom.get().filter(s??Se))},this.add=s=>{this.atom.get().includes(s)||this.atom.set(this.atom.get().concat([s]))},this.remove=s=>{const o=this.atom.get().indexOf(s);if(o<0)return;const i=this.atom.get().slice(0);i.splice(o,1),this.atom.set(i)},this.toggle=(s,o)=>{const i=this.atom.get().slice(),f=i.indexOf(s);f<0?o?i.unshift(s):i.push(s):i.splice(f,1),this.atom.set(i)}}}const Se=t=>t;class ee extends L{constructor(e,r){super(r),this.atom=e,this.toggle=()=>{this.atom.set(!this.atom.get())}}}class te extends L{constructor(e,r){super(r),this.atom=e,this.setValue=(s,o)=>{const i=new Map(this.atom.get());i.set(s,o),this.atom.set(i)},this.delete=s=>{const o=new Map(this.atom.get());o.delete(s),this.atom.set(o)},this.toggle=(s,o)=>{const i=new Map(this.atom.get());i.has(s)?i.delete(s):i.set(s,o),this.atom.set(i)},this.clear=()=>{this.atom.set(new Map)},this.atom=e}}class se extends L{constructor(e,r){super(r),this.atom=e,this.increment=s=>{this.atom.set(+this.atom.get()+(s??1))}}}class ne extends k{constructor(e,r){super(r),this.atom=e,this.setPartial=s=>this.atom.set(o=>({...o,...typeof s=="function"?s(this.atom.get()):s})),this.update=s=>{const o=this.atom.get(),i=this.updateValue(o,s);i!==o&&this.atom.set(i)},this.setDeepPartial=(s,o,i,f=$.keyPathSeparator||".")=>{if(!f)return;if(s.includes(f)){let A=s.split(f);const p=A[A.length-1];A=A.slice(0,-1);const b={...this.atom.get()};let h=b,d=i;for(const w of A){d=d==null?void 0:d[Array.isArray(d)?"0":w];const M=h[re(h,w)]??(Array.isArray(d)?[]:{});if(M==null||typeof M!="object"){if(i==null)throw"Incorrect path for setDeepPartial";const x=typeof o=="function"?o(void 0):o;this.atom.get()[s]!==x&&this.setPartial({[s]:x});return}h=h[re(h,w)]=Array.isArray(M)?[...M]:{...M}}const q=h[p];h[p]=typeof o=="function"?o(h[p]):o,q!==h[p]&&this.atom.set(b);return}const m=this.atom.get()[s],g=typeof o=="function"?o(m):o;g!==m&&this.setPartial({[s]:g})}}}const re=(t,e)=>Array.isArray(t)?`${+e}`:e;class oe extends L{constructor(e,r){super(r),this.atom=e,this.add=s=>{this.atom.set(new Set(this.atom.get()).add(s))},this.delete=s=>{const o=new Set(this.atom.get());o.delete(s),this.atom.set(o)},this.toggle=s=>{const o=new Set(this.atom.get());o.has(s)?o.delete(s):o.add(s),this.atom.set(o)},this.clear=()=>{this.atom.set(new Set)},this.atom=e}}const be=(t,e,r)=>{const s=typeof r=="object"&&r!=null&&"do"in r?r.do((i,f)=>e.set(i,f),()=>e.get(),e,(i,f,m)=>e.setDeferred(i,f,m)):null,o={};return s&&Object.keys(s).forEach(i=>Object.defineProperty(o,i,{get:()=>s[i]})),typeof t=="number"?new se(e,s):typeof t=="boolean"?new ee(e,s):Array.isArray(t)?new O(e,s):t instanceof Set?new oe(e,s):t instanceof Map?new te(e,s):t instanceof Object?new ne(e,s):new L(s)};class ce{constructor(e,r){e=typeof e=="function"?e():e;const s=n=>A=n,o=()=>A,i=new Set,f=n=>n(h());let m=!0,g=!1,A=e,p,b=()=>{},h=()=>o(),d=null,q=()=>{const n=be(e,w,r);return q=()=>n,n};const w=new Proxy(this,{get:(n,a)=>a==="do"?q():n[a],set:De}),M=()=>{m=!0,g!==!0&&b(h()),g=!1;try{B.postMessage({key:u,value:o()})}catch{}},x=(n,a)=>{const y=typeof n=="function"?n(h()):n;y!==h()&&(s(y),g=a,m&&(m=!1,i.forEach(f),queueMicrotask(M)))};this.set=(n,a)=>x(n,a),this.get=()=>h(),this.initialValue=e,this.isInitialValue=()=>e===o(),this.subscribe=n=>(i.add(n),()=>{i.delete(n)}),this.reset=()=>{x(e,!0)};const Te=(n,a)=>{x(n,a),p=void 0};if(this.setDeferred=(n,a=500,y,D=!0)=>{D&&p===void 0&&x(n,y),clearTimeout(p),p=setTimeout(Te,a,n,y)},r==null)return w;let S=null,z=null,W=!0,G=!0,H=!1,T=0,_=0,le=-1,V=e instanceof Set?n=>new Set(n):e instanceof Map?n=>{if(!n||typeof n!="object")return new Map;const a=new Map;for(const y in n)try{a.set(JSON.parse(y),n[y])}catch{}return a}:n=>n,E=e instanceof Set?n=>{if(n instanceof Set)return Array.from(n);throw console.error(n),"The value is not Set instance"}:e instanceof Map?n=>{if(n instanceof Map){const a={};return n.forEach((y,D)=>{try{a[JSON.stringify(D)]=y}catch{}}),a}throw console.error(n),"The value is not Set instance"}:n=>n;if(typeof r=="string")S=r;else if("storeKey"in r)W=r.warnOnDuplicateStoreKey??W,G=r.listenStorageChanges??G,S=r.storeKey,V=r.unzipValue??V,E=r.zipValue??E,H=r.unchangable??H,T=r.securifyKeyLevel??$.securifyKeyLevel??T,_=r.securifyValueLevel??$.securifyValueLevel??_,z=r.exp??z;else return w;const Q=T?I(S,T):S,u=`${_?J:C}${Q}`;if(T){const n=`${C}${S}`;n in c&&(c[u]=c[n],delete c[n])}else{const n=`${C}${I(S,T)}`;n in c&&(c[u]=c[n],delete c[n])}const K=z===null||!(z(w,u in c)instanceof Date)?n=>I([E(n)],0):n=>(d??(d={}),d.exp=z(w,u in c).getTime(),d.exp-Date.now()<24*60*60*1e3&&(clearTimeout(le),clearTimeout(ie[u]),le=setTimeout(()=>this.reset(),d.exp-Date.now())),d.exp=Math.trunc(d.exp/1e3),I([E(n),d],0));if(_){const n=`${C}${Q}`,a=E,y=V;if(E=D=>{try{return I([a(D)],_)}catch{return delete c[u],""}},n in c){const D=`${C}${I(S,T)}`;try{c[D]=K(V(U(c[n],0)[0])),delete c[n]}catch{}}V=D=>{try{return y(U(D,_)[0])}catch{return delete c[u],""}}}else delete c[`${J}${Q}`];const fe=n=>{const a=U(n,0);return d=a[1],V(a[0])};let he=!0;if(v[u]=w,c[`atom/${S}`]&&(c[u]||(c[u]=`[${c[`atom/${S}`]}]`),delete c[`atom/${S}`]),h=()=>{if(h=o,he){he=!1;try{s(u in c?fe(c[u]):e)}catch{console.warn("Invalid json value",c[u])}}return o()},b=n=>{if(n===e){this.reset();return}c[u]=K(n)},this.reset=()=>{delete c[u],x(e,!0)},W&&P[u]!==void 0&&console.warn("Duplicate Atom key",S),G)if(H){let n=!1,a;N[u]=this,P[u]=()=>{clearTimeout(a),a=setTimeout(()=>n=!1,10),!n&&(n=!0,c[u]=K(o()))}}else P[u]=n=>{if(n.newValue===null){this.reset();return}try{x(fe(n.newValue))}catch{console.warn("Invalid json value",n.newValue)}};return w}}let B;try{B=new BroadcastChannel("updateHere"),B.addEventListener("message",t=>{var e;(e=N[t.data.key])==null||e.set(t.data.value,!0)})}catch{}const c=localStorage,P={},N={},De=(t,e)=>{throw`${e} is readonly property`};window.addEventListener("storage",t=>{var e;t.key===null||t.newValue===t.oldValue||(e=P[t.key])==null||e.call(P,t)});const xe=c.setItem.bind(c),$e=c.removeItem.bind(c);c.setItem=(t,e)=>{N[t]===void 0&&xe.call(c,t,e)},c.removeItem=t=>{N[t]===void 0&&$e.call(c,t)};const Me=/"exp":\s*(\d+)/,C="atom\\",J="atom`s\\",v={},ie={},ae=/[a-z]/gi,R=5,F={};for(let t=54;t<80;t++){if(t===68||t===72||t===55)continue;const e=String.fromCharCode(t+43).toUpperCase(),r=String.fromCharCode(t+43).toLowerCase();F[e]=r,F[r]=e}const ue=t=>F[t]??t,I=(()=>{const t=[e=>JSON.stringify(e),e=>btoa(encodeURI(t[0](e))),e=>{const r=t[1](e);return`${r.slice(0,R)}${r.slice(R).replace(ae,ue)}`},e=>btoa(t[2](e))];return(e,r)=>{try{return t[r](e)}catch(s){if(r===0)throw s;return t[0](e)}}})(),U=(()=>{const t=[e=>JSON.parse(e),e=>t[0](decodeURI(atob(e))),e=>t[1](`${e.slice(0,R)}${e.slice(R).replace(ae,ue)}`),e=>t[2](atob(e))];return(e,r)=>{try{return t[r](e)}catch(s){if(r===0)throw s;return t[0](e)}}})();setTimeout(()=>{Object.keys(c).forEach(t=>{var s;if(typeof c[t]!="string"||!t.startsWith(C)&&!t.startsWith(J))return;const e=+((s=c[t].match(Me))==null?void 0:s[1]);if(!e||e*1e3-Date.now()>24*60*60*1e3)return;const r=U(c[t],0);!Array.isArray(r)||r[1]==null||!("exp"in r[1])||r[1].exp!==e||(ie[t]=setTimeout(()=>{v[t]?v[t].reset():delete c[t]},e*1e3-Date.now()))})},1e3),l.Atom=ce,l.AtomArrayDoActions=O,l.AtomBooleanDoActions=ee,l.AtomMapDoActions=te,l.AtomNumberDoActions=se,l.AtomObjectDoActions=ne,l.AtomSetDoActions=oe,l.atom=pe,l.configureAtomaric=me,l.configuredOptions=$,l.useAtom=ye,l.useAtomDo=ge,l.useAtomGet=Ae,l.useAtomSet=Z,l.useAtomSetDeferred=de,l.useAtomValue=Y,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
import { atom, configureAtomaric } from '../lib';
|
|
3
|
+
import { makeFullKey, wait } from '../utils';
|
|
4
|
+
|
|
5
|
+
configureAtomaric({
|
|
6
|
+
useSyncExternalStore,
|
|
7
|
+
keyPathSeparator: '.',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe('Map', () => {
|
|
11
|
+
test('do actions', async () => {
|
|
12
|
+
type Value = number | { asasa: '' };
|
|
13
|
+
const testAtom = atom(new Map<string, Value>(), {
|
|
14
|
+
storeKey: 'map:test',
|
|
15
|
+
do: (set, get) => ({
|
|
16
|
+
filterKeyValues: () => {
|
|
17
|
+
const newMap = new Map();
|
|
18
|
+
get().forEach((value, key) => {
|
|
19
|
+
if (value) newMap.set(key, value);
|
|
20
|
+
});
|
|
21
|
+
set(newMap);
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
testAtom.do.setValue('!', 1);
|
|
27
|
+
testAtom.do.setValue('@', 0);
|
|
28
|
+
testAtom.do.setValue('#', { asasa: '' });
|
|
29
|
+
testAtom.do.setValue('', 123);
|
|
30
|
+
await wait();
|
|
31
|
+
|
|
32
|
+
expect(localStorage[makeFullKey('map:test')]).toEqual(
|
|
33
|
+
'[{"\\"!\\"":1,"\\"@\\"":0,"\\"#\\"":{"asasa":""},"\\"\\"":123}]',
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(testAtom.get()).toEqual(
|
|
37
|
+
new Map<string, Value>([
|
|
38
|
+
['!', 1],
|
|
39
|
+
['@', 0],
|
|
40
|
+
['#', { asasa: '' }],
|
|
41
|
+
['', 123],
|
|
42
|
+
]),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
testAtom.do.filterKeyValues();
|
|
46
|
+
await wait();
|
|
47
|
+
|
|
48
|
+
expect(localStorage[makeFullKey('map:test')]).toEqual('[{"\\"!\\"":1,"\\"#\\"":{"asasa":""},"\\"\\"":123}]');
|
|
49
|
+
|
|
50
|
+
testAtom.do.delete('#');
|
|
51
|
+
await wait();
|
|
52
|
+
|
|
53
|
+
expect(localStorage[makeFullKey('map:test')]).toEqual('[{"\\"!\\"":1,"\\"\\"":123}]');
|
|
54
|
+
|
|
55
|
+
testAtom.do.toggle('#', 555);
|
|
56
|
+
await wait();
|
|
57
|
+
|
|
58
|
+
expect(localStorage[makeFullKey('map:test')]).toEqual('[{"\\"!\\"":1,"\\"\\"":123,"\\"#\\"":555}]');
|
|
59
|
+
|
|
60
|
+
testAtom.do.toggle('', 999);
|
|
61
|
+
testAtom.do.toggle('!', 1234567890);
|
|
62
|
+
await wait();
|
|
63
|
+
|
|
64
|
+
expect(localStorage[makeFullKey('map:test')]).toEqual('[{"\\"#\\"":555}]');
|
|
65
|
+
|
|
66
|
+
testAtom.do.clear();
|
|
67
|
+
await wait();
|
|
68
|
+
|
|
69
|
+
expect(localStorage[makeFullKey('map:test')]).toEqual('[{}]');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Atom } from '../../types';
|
|
2
|
+
import { AtomDoActionsBasic } from './_Basic';
|
|
3
|
+
|
|
4
|
+
export class AtomMapDoActions<
|
|
5
|
+
MapValue extends Map<any, any>,
|
|
6
|
+
Key extends MapValue extends Map<infer K, any> ? K : never,
|
|
7
|
+
Value extends MapValue extends Map<any, infer V> ? V : never,
|
|
8
|
+
> extends AtomDoActionsBasic {
|
|
9
|
+
constructor(private atom: Atom<MapValue>, actions: Record<string, Function> | nil) {
|
|
10
|
+
super(actions);
|
|
11
|
+
this.atom = atom;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** like the Map.prototype.set() method */
|
|
15
|
+
setValue = (key: Key, value: Value) => {
|
|
16
|
+
const newMap = new Map(this.atom.get());
|
|
17
|
+
newMap.set(key, value);
|
|
18
|
+
this.atom.set(newMap as never);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** like the Map.prototype.delete() method */
|
|
22
|
+
delete = (key: Key) => {
|
|
23
|
+
const newMap = new Map(this.atom.get());
|
|
24
|
+
newMap.delete(key);
|
|
25
|
+
this.atom.set(newMap as never);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** will add value if it doesn't exist, otherwise delete */
|
|
29
|
+
toggle = (key: Key, value: Value) => {
|
|
30
|
+
const newMap = new Map(this.atom.get());
|
|
31
|
+
|
|
32
|
+
if (newMap.has(key)) newMap.delete(key);
|
|
33
|
+
else newMap.set(key, value);
|
|
34
|
+
|
|
35
|
+
this.atom.set(newMap as never);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** like the Map.prototype.clear() method */
|
|
39
|
+
clear = () => {
|
|
40
|
+
this.atom.set(new Map() as never);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -8,7 +8,7 @@ configureAtomaric({
|
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
describe('Object', () => {
|
|
11
|
-
test('setDeepPartial()', async () => {
|
|
11
|
+
test('do.setDeepPartial()', async () => {
|
|
12
12
|
const b = { c: [{ d: 8, e: 'e', f: 'F', g: { h: 'HHH' } }] };
|
|
13
13
|
const a = { f: { g: '' }, b };
|
|
14
14
|
const testAtom = atom({ a, b });
|
|
@@ -29,7 +29,7 @@ describe('Object', () => {
|
|
|
29
29
|
expect(testAtom.get().b.c[8].e).toEqual('EE');
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
test('setDeepPartial() with first numeric prop', async () => {
|
|
32
|
+
test('do.setDeepPartial() with first numeric prop', async () => {
|
|
33
33
|
enum Num {
|
|
34
34
|
num = 123,
|
|
35
35
|
}
|
|
@@ -42,7 +42,17 @@ describe('Object', () => {
|
|
|
42
42
|
expect(testAtom.get()[Num.num].a).toEqual('AA');
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
test('
|
|
45
|
+
test('do.setPartial()', async () => {
|
|
46
|
+
const testAtom = atom((): Record<number, unknown> => ({ 2: { a: 'A' } }));
|
|
47
|
+
|
|
48
|
+
testAtom.do.setPartial({ 3: { b: 'B' } });
|
|
49
|
+
testAtom.do.setPartial({ 4: [] });
|
|
50
|
+
await wait();
|
|
51
|
+
|
|
52
|
+
expect(testAtom.get()).toEqual({ 2: { a: 'A' }, 3: { b: 'B' }, 4: [] });
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('do.update()', async () => {
|
|
46
56
|
const init = { a: { b: { c: { d: { e: 'E' } }, f: { g: {} } }, h: { i: { j: {} } } } };
|
|
47
57
|
const testAtom = atom(init);
|
|
48
58
|
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useSyncExternalStore } from 'react';
|
|
2
2
|
import { AtomArrayDoActions } from '../src/do.classes/Array';
|
|
3
3
|
import { AtomBooleanDoActions } from '../src/do.classes/Boolean';
|
|
4
|
+
import { AtomMapDoActions } from '../src/do.classes/Map';
|
|
4
5
|
import { AtomNumberDoActions } from '../src/do.classes/Number';
|
|
5
6
|
import { AtomObjectDoActions } from '../src/do.classes/Object';
|
|
6
7
|
import { AtomSetDoActions } from '../src/do.classes/Set';
|
|
@@ -78,6 +79,8 @@ export type ObjectActionsSetDeepPartialDoAction<Value> = <
|
|
|
78
79
|
|
|
79
80
|
export type DefaultActions<Value> = Value extends Set<infer Val>
|
|
80
81
|
? AtomSetDoActions<Val>
|
|
82
|
+
: Value extends Map<infer Key, infer Val>
|
|
83
|
+
? AtomMapDoActions<Value, Key, Val>
|
|
81
84
|
: Value extends boolean
|
|
82
85
|
? AtomBooleanDoActions
|
|
83
86
|
: Value extends (infer Val)[]
|