@exodus/atoms 10.2.1 → 10.3.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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.2.2...@exodus/atoms@10.3.0) (2026-04-03)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- feat(atoms): pure withSerialization optimization (#15822)
|
|
11
|
+
|
|
12
|
+
## [10.2.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.2.1...@exodus/atoms@10.2.2) (2026-04-02)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- fix(atoms): resolve promise hanging anti-pattern in filter enhancer (#15780)
|
|
17
|
+
|
|
6
18
|
## [10.2.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.2.0...@exodus/atoms@10.2.1) (2026-04-02)
|
|
7
19
|
|
|
8
20
|
### Bug Fixes
|
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)) {
|
|
@@ -3,6 +3,7 @@ type Params<T, S> = {
|
|
|
3
3
|
atom: Atom<S>;
|
|
4
4
|
serialize: (value: T) => S | Promise<S>;
|
|
5
5
|
deserialize: (serialized: S) => T | Promise<T>;
|
|
6
|
+
pure?: boolean;
|
|
6
7
|
};
|
|
7
|
-
declare const withSerialization: <T, S>({ atom, serialize: customSerialize, deserialize: customDeserialize, }: Params<T, S>) => Atom<T>;
|
|
8
|
+
declare const withSerialization: <T, S>({ atom, serialize: customSerialize, deserialize: customDeserialize, pure, }: Params<T, S>) => Atom<T>;
|
|
8
9
|
export default withSerialization;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isSetter } from '../utils/guards.js';
|
|
2
|
-
const withSerialization = ({ atom, serialize: customSerialize, deserialize: customDeserialize, }) => {
|
|
2
|
+
const withSerialization = ({ atom, serialize: customSerialize, deserialize: customDeserialize, pure = false, }) => {
|
|
3
3
|
const serialize = (value) => (value === undefined ? undefined : customSerialize(value));
|
|
4
4
|
const deserialize = (value) => (value === undefined ? undefined : customDeserialize(value));
|
|
5
5
|
const get = async () => {
|
|
@@ -8,7 +8,13 @@ const withSerialization = ({ atom, serialize: customSerialize, deserialize: cust
|
|
|
8
8
|
};
|
|
9
9
|
const set = async (value) => {
|
|
10
10
|
if (isSetter(value)) {
|
|
11
|
-
return atom.set(async (previousValue) =>
|
|
11
|
+
return atom.set(async (previousValue) => {
|
|
12
|
+
const deserialized = await deserialize(previousValue);
|
|
13
|
+
const updated = await value(deserialized);
|
|
14
|
+
if (pure && updated === deserialized)
|
|
15
|
+
return previousValue;
|
|
16
|
+
return serialize(updated);
|
|
17
|
+
});
|
|
12
18
|
}
|
|
13
19
|
const serialized = await serialize(value);
|
|
14
20
|
return atom.set(serialized);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/atoms",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
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": "d208a04e76309bf9f6b24cb5403250fff4b0e78f"
|
|
60
60
|
}
|