valdres 0.2.0-alpha.56 → 0.2.0-alpha.57

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/dist/index.js CHANGED
@@ -130,10 +130,10 @@ var isSelector = (state) => state && Object.hasOwn(state, "get");
130
130
  // src/utils/isSelectorFamily.ts
131
131
  var isSelectorFamily = (state) => state && Object.hasOwn(state, "__valdresSelectorFamilyMap");
132
132
 
133
+ // src/lib/isFunction.ts
134
+ var isFunction = (value) => typeof value === "function";
135
+
133
136
  // src/lib/setAtom.ts
134
- var isFunction = (value) => {
135
- return typeof value === "function";
136
- };
137
137
  var setAtom = (atom, newValue, data, skipOnSet = false) => {
138
138
  const currentValue = getState(atom, data);
139
139
  if (isFunction(newValue)) {
@@ -653,7 +653,7 @@ var transaction = (callback, data, autoCommit = true) => {
653
653
  const txnSet = (atom, value) => {
654
654
  if (!isAtom(atom))
655
655
  throw new Error("Not an atom");
656
- if (typeof value === "function") {
656
+ if (isFunction(value)) {
657
657
  const currentValue = txnGet(atom);
658
658
  value = value(currentValue);
659
659
  }
@@ -665,6 +665,7 @@ var transaction = (callback, data, autoCommit = true) => {
665
665
  recursivlyResetTxnSelectorCache(atom, txnSubscribers, txnSelectorCache);
666
666
  }
667
667
  txnAtomMap.set(atom, value);
668
+ return value;
668
669
  };
669
670
  const txnReset = (atom) => {
670
671
  const value = getAtomInitValue(atom, data);
@@ -774,7 +775,7 @@ var store = (id) => {
774
775
  return storeFromStoreData(data);
775
776
  };
776
777
  // package.json
777
- var version = "0.2.0-alpha.55";
778
+ var version = "0.2.0-alpha.56";
778
779
 
779
780
  // src/globalStore.ts
780
781
  if (globalThis.__valdres__) {
@@ -0,0 +1 @@
1
+ export declare const isFunction: (value: unknown) => value is Function;
@@ -1 +1 @@
1
- export type EqualFunc<Value> = (a: Value, b: Value) => boolean;
1
+ export type EqualFunc<Value = any> = (a: Value, b: Value) => boolean;
@@ -1,3 +1,5 @@
1
1
  import type { Atom } from "./Atom";
2
2
  import type { SetAtomValue } from "./SetAtomValue";
3
- export type SetAtom<Value = any> = (atom: Atom<Value>, value: SetAtomValue<Value>) => void;
3
+ export type SetAtom = {
4
+ <V>(atom: Atom<V>, value: SetAtomValue<V>): V;
5
+ };
@@ -1,8 +1,12 @@
1
+ import type { Atom } from "./Atom";
1
2
  import type { GetValue } from "./GetValue";
2
3
  import type { ResetAtom } from "./ResetAtom";
3
4
  import type { SetAtom } from "./SetAtom";
4
5
  import type { StoreData } from "./StoreData";
5
6
  import type { TransactionFn } from "./TransactionFn";
7
+ export type SetAtom2 = {
8
+ <V>(atom: Atom<V>, value: V): V;
9
+ };
6
10
  export type TransactionInterface = {
7
11
  set: SetAtom;
8
12
  get: GetValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valdres",
3
- "version": "0.2.0-alpha.56",
3
+ "version": "0.2.0-alpha.57",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Eigil Sagafos"
@@ -36,5 +36,5 @@
36
36
  "access": "public",
37
37
  "registry": "https://registry.npmjs.org/"
38
38
  },
39
- "gitHead": "b3f91557fd99701880610a9ef2d317fe84135f64"
39
+ "gitHead": "ac804793bb3c428a50d3f2baf46d18a7dfeefee3"
40
40
  }