@exodus/atoms 10.2.2 → 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,12 @@
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
+
6
12
  ## [10.2.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.2.1...@exodus/atoms@10.2.2) (2026-04-02)
7
13
 
8
14
  ### Bug Fixes
@@ -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) => serialize(await value(await deserialize(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.2.2",
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": "55540ff3a6815d24d42836269d8a8541289c5e45"
59
+ "gitHead": "d208a04e76309bf9f6b24cb5403250fff4b0e78f"
60
60
  }