valdres 0.2.0-alpha.67 → 0.2.0-alpha.68
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
|
@@ -899,6 +899,13 @@ function atom(defaultValue, options) {
|
|
|
899
899
|
...options
|
|
900
900
|
};
|
|
901
901
|
}
|
|
902
|
+
// src/selector.ts
|
|
903
|
+
var selector = (get, options) => {
|
|
904
|
+
if (!options)
|
|
905
|
+
return { equal, get };
|
|
906
|
+
return { equal, ...options, get };
|
|
907
|
+
};
|
|
908
|
+
|
|
902
909
|
// src/lib/atomFamilyAtom.ts
|
|
903
910
|
function atomFamilyAtom(defaultValue, options) {
|
|
904
911
|
if (options.global) {
|
|
@@ -964,13 +971,6 @@ var stableStringify = (x) => {
|
|
|
964
971
|
return stableStringifyRecurse(x);
|
|
965
972
|
};
|
|
966
973
|
|
|
967
|
-
// src/selector.ts
|
|
968
|
-
var selector = (get, options) => {
|
|
969
|
-
if (!options)
|
|
970
|
-
return { equal, get };
|
|
971
|
-
return { equal, ...options, get };
|
|
972
|
-
};
|
|
973
|
-
|
|
974
974
|
// src/lib/createAtomFamily.ts
|
|
975
975
|
var createOptions = (options = {}, family, familyKey, keyStringified) => {
|
|
976
976
|
if (options.name) {
|
|
@@ -1052,6 +1052,37 @@ var createStoreWithSelectorSet = (id) => {
|
|
|
1052
1052
|
store2.kind = "storeWithSelectorSet";
|
|
1053
1053
|
return store2;
|
|
1054
1054
|
};
|
|
1055
|
+
// src/indexConstructor.ts
|
|
1056
|
+
var index = (family, callback) => {
|
|
1057
|
+
const map = new Map;
|
|
1058
|
+
return (term) => {
|
|
1059
|
+
const termKey = stableStringify(term);
|
|
1060
|
+
if (map.has(termKey))
|
|
1061
|
+
return map.get(termKey);
|
|
1062
|
+
const itemSelectorMap = new Map;
|
|
1063
|
+
const selectorMapIndex = selector((get) => {
|
|
1064
|
+
const ids = get(family);
|
|
1065
|
+
ids.forEach((id) => {
|
|
1066
|
+
if (itemSelectorMap.has(id))
|
|
1067
|
+
return;
|
|
1068
|
+
itemSelectorMap.set(id, selector((get2) => callback(get2(family(id)), term)));
|
|
1069
|
+
});
|
|
1070
|
+
return itemSelectorMap;
|
|
1071
|
+
});
|
|
1072
|
+
const filteredSelector = selector((get) => {
|
|
1073
|
+
const map2 = get(selectorMapIndex);
|
|
1074
|
+
const res = [];
|
|
1075
|
+
map2.forEach((selector2, key) => {
|
|
1076
|
+
if (get(selector2)) {
|
|
1077
|
+
res.push(key);
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
return res;
|
|
1081
|
+
});
|
|
1082
|
+
map.set(termKey, filteredSelector);
|
|
1083
|
+
return filteredSelector;
|
|
1084
|
+
};
|
|
1085
|
+
};
|
|
1055
1086
|
// src/selectorFamily.ts
|
|
1056
1087
|
var createOptions2 = (options = {}, family, familyKey, keyStringified) => {
|
|
1057
1088
|
if (options.name) {
|
|
@@ -1106,6 +1137,7 @@ export {
|
|
|
1106
1137
|
isFamily,
|
|
1107
1138
|
isAtomFamily,
|
|
1108
1139
|
isAtom,
|
|
1140
|
+
index,
|
|
1109
1141
|
globalStore,
|
|
1110
1142
|
createStoreWithSelectorSet,
|
|
1111
1143
|
atomFamily,
|
|
@@ -5,6 +5,7 @@ export { atom } from "./atom";
|
|
|
5
5
|
export { atomFamily } from "./atomFamily";
|
|
6
6
|
export { createStoreWithSelectorSet } from "./createStoreWithSelectorSet";
|
|
7
7
|
export { globalStore } from "./globalStore";
|
|
8
|
+
export { index } from "./indexConstructor";
|
|
8
9
|
export { selector } from "./selector";
|
|
9
10
|
export { selectorFamily } from "./selectorFamily";
|
|
10
11
|
export { store } from "./store";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AtomFamily } from "./types/AtomFamily";
|
|
2
|
+
import type { FamilyKey } from "./types/FamilyKey";
|
|
3
|
+
import type { Selector } from "./types/Selector";
|
|
4
|
+
export declare const index: <T, K extends FamilyKey = FamilyKey, V = unknown>(family: AtomFamily<K, V>, callback: (value: V, term: T) => boolean) => ((term: T) => Selector<T[]>);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AtomFamily } from "../types/AtomFamily";
|
|
2
|
-
import type { AtomOptions } from "../types/AtomOptions";
|
|
3
2
|
import type { AtomFamilyDefaultValue } from "../types/AtomFamilyDefaultValue";
|
|
3
|
+
import type { AtomOptions } from "../types/AtomOptions";
|
|
4
4
|
export declare const createAtomFamily: <Key, Value>(defaultValue: AtomFamilyDefaultValue<Key, Value>, options?: AtomOptions<Value>) => AtomFamily<Key, Value>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valdres",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.68",
|
|
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": "
|
|
39
|
+
"gitHead": "81c34343833ad6b9755b0e7ada7f561206974373"
|
|
40
40
|
}
|