@exodus/atoms 10.0.0 → 10.1.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.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.0.0...@exodus/atoms@10.1.0) (2026-01-29)
7
+
8
+ ### Features
9
+
10
+ - feat: infer result atom in `filter`, accept readonly atoms (#15069)
11
+
6
12
  ## [10.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@9.0.3...@exodus/atoms@10.0.0) (2025-10-08)
7
13
 
8
14
  ### ⚠ BREAKING CHANGES
@@ -1,8 +1,8 @@
1
- import type { Atom, ReadonlyAtom } from '../utils/types.js';
1
+ import type { AnyAtom, ReadonlyAtom } from '../utils/types.js';
2
2
  type CombinedValue<T> = {
3
- [Key in keyof T]: T[Key] extends Atom<infer U> ? U : never;
3
+ [Key in keyof T]: T[Key] extends AnyAtom<infer U> ? U : never;
4
4
  };
5
5
  declare const combine: <T, U extends {
6
- [key: string]: Atom<T>;
6
+ [key: string]: AnyAtom<T>;
7
7
  }>(atoms: U) => ReadonlyAtom<CombinedValue<U>>;
8
8
  export default combine;
@@ -1,2 +1,6 @@
1
- import type { Atom } from '../utils/types.js';
2
- export default function filter<T>(atom: Atom<T>, predicate: (value: T) => boolean): Atom<T>;
1
+ import type { AnyAtom, AtomValue, SetAtomValue } from '../utils/types.js';
2
+ type Predicate<A extends AnyAtom, S extends AtomValue<A>> = ((value: AtomValue<A>) => value is S) | ((value: AtomValue<A>) => unknown);
3
+ type FilteredValue<A extends AnyAtom, P extends Predicate<A, any>> = P extends ((value: AtomValue<A>) => value is infer S extends AtomValue<A>) ? S : AtomValue<A>;
4
+ type ResultAtom<A extends AnyAtom, P extends Predicate<A, any>> = SetAtomValue<A, FilteredValue<A, P>>;
5
+ export default function filter<A extends AnyAtom, S extends AtomValue<A>, P extends Predicate<A, S>>(atom: A, predicate: P): ResultAtom<A, P>;
6
+ export {};
@@ -26,3 +26,6 @@ export interface Keystore {
26
26
  deleteSecret(key: string, options?: object): Promise<string>;
27
27
  }
28
28
  export type Logger = Pick<Console, 'trace' | 'debug' | 'error' | 'info' | 'log' | 'warn'>;
29
+ export type AnyAtom<V = any> = Atom<V> | ReadonlyAtom<V>;
30
+ export type AtomValue<A extends AnyAtom> = A extends AnyAtom<infer V> ? V : never;
31
+ export type SetAtomValue<A extends AnyAtom, V> = A extends Atom<any> ? Atom<V> : A extends ReadonlyAtom<any> ? ReadonlyAtom<V> : never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/atoms",
3
- "version": "10.0.0",
3
+ "version": "10.1.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",
@@ -12,7 +12,8 @@
12
12
  "scripts": {
13
13
  "build": "run -T tsc -p tsconfig.build.json",
14
14
  "clean": "run -T tsc --build --clean",
15
- "test": "run -T exodus-test --jest --esbuild",
15
+ "test": "run -T exodus-test --jest --esbuild && run test:types",
16
+ "test:types": "tsc -p tsconfig.json --noEmit",
16
17
  "lint": "run -T eslint .",
17
18
  "lint:fix": "yarn lint --fix",
18
19
  "prepublishOnly": "yarn run -T build --scope @exodus/atoms"
@@ -55,5 +56,5 @@
55
56
  "publishConfig": {
56
57
  "provenance": false
57
58
  },
58
- "gitHead": "72e1044962bc88cb5e22fb69c56997d11e3fdd20"
59
+ "gitHead": "b381cc2639d8235acce2377e83ed27ce4dd86e0c"
59
60
  }