@exodus/atoms 10.2.0 → 10.2.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/CHANGELOG.md +14 -0
- package/lib/countdown-lock.js +1 -1
- package/lib/enhancers/filter.js +10 -8
- package/lib/factories/sequenced-keystore.js +6 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.2.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.2.1...@exodus/atoms@10.2.2) (2026-04-02)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- fix(atoms): resolve promise hanging anti-pattern in filter enhancer (#15780)
|
|
11
|
+
|
|
12
|
+
## [10.2.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.2.0...@exodus/atoms@10.2.1) (2026-04-02)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- fix(atoms): sequenced-keystore get() idempotency when isSoleWriter is true (#15787)
|
|
17
|
+
|
|
18
|
+
- fix(atoms): validate key membership in countdown-lock unlock (#15789)
|
|
19
|
+
|
|
6
20
|
## [10.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.1.0...@exodus/atoms@10.2.0) (2026-03-23)
|
|
7
21
|
|
|
8
22
|
### Features
|
package/lib/countdown-lock.js
CHANGED
|
@@ -12,7 +12,7 @@ const createCountdownLock = (keys) => {
|
|
|
12
12
|
return {
|
|
13
13
|
promise: deferred.promise,
|
|
14
14
|
unlock: (key) => {
|
|
15
|
-
if (!unlockedKeys.includes(key))
|
|
15
|
+
if (keys.includes(key) && !unlockedKeys.includes(key))
|
|
16
16
|
unlockedKeys.push(key);
|
|
17
17
|
if (unlockedKeys.length === keys.length) {
|
|
18
18
|
deferred.resolve();
|
package/lib/enhancers/filter.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import makeConcurrent from 'make-concurrent';
|
|
2
2
|
const limitConcurrency = (fn) => makeConcurrent(fn, { concurrency: 1 });
|
|
3
3
|
export default function filter(atom, predicate) {
|
|
4
|
-
const get = limitConcurrency(
|
|
4
|
+
const get = limitConcurrency(async () => {
|
|
5
5
|
const value = await atom.get();
|
|
6
6
|
if (predicate(value)) {
|
|
7
|
-
return
|
|
7
|
+
return value;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const unsubscribe = atom.observe((value) => {
|
|
11
|
+
if (predicate(value)) {
|
|
12
|
+
unsubscribe();
|
|
13
|
+
resolve(value);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
14
16
|
});
|
|
15
|
-
})
|
|
17
|
+
});
|
|
16
18
|
const observe = (listener) => {
|
|
17
19
|
return atom.observe((value) => {
|
|
18
20
|
if (predicate(value)) {
|
|
@@ -10,6 +10,7 @@ const createSequencedKeystoreAtom = ({ keystore, config: { key, separator = '.',
|
|
|
10
10
|
enable: isSoleWriter,
|
|
11
11
|
});
|
|
12
12
|
let cache;
|
|
13
|
+
let isCachePopulated = false;
|
|
13
14
|
const getKey = (index) => key.endsWith(separator) ? `${key}${index}` : `${key}${separator}${index}`;
|
|
14
15
|
const getByIndex = async (index) => {
|
|
15
16
|
const key = getKey(index);
|
|
@@ -48,18 +49,20 @@ const createSequencedKeystoreAtom = ({ keystore, config: { key, separator = '.',
|
|
|
48
49
|
}
|
|
49
50
|
if (isSoleWriter) {
|
|
50
51
|
cache = value;
|
|
52
|
+
isCachePopulated = true;
|
|
51
53
|
await notify(value);
|
|
52
54
|
}
|
|
53
55
|
};
|
|
54
56
|
const get = async () => {
|
|
55
|
-
if (
|
|
57
|
+
if (isCachePopulated)
|
|
56
58
|
return cache;
|
|
57
59
|
const items = await list();
|
|
58
|
-
const value = items.map((item) => item.value);
|
|
60
|
+
const value = items.length === 0 ? undefined : items.map((item) => item.value);
|
|
59
61
|
if (isSoleWriter) {
|
|
60
62
|
cache = value;
|
|
63
|
+
isCachePopulated = true;
|
|
61
64
|
}
|
|
62
|
-
return
|
|
65
|
+
return value;
|
|
63
66
|
};
|
|
64
67
|
return enforceObservableRules({
|
|
65
68
|
get,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/atoms",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.2",
|
|
4
4
|
"description": "Abstraction for encapsulating a piece of data behind a simple unified interface: get, set, observe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"provenance": false
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "55540ff3a6815d24d42836269d8a8541289c5e45"
|
|
60
60
|
}
|