Skip to content

Commit 936ce0a

Browse files
committed
~ Simplify get internals slightly
1 parent 026e8f0 commit 936ce0a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/2n8.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,11 @@ export function createStore<Store extends TwoAndEight>(
9898
const cache = {} as Store
9999

100100
const get = <Field extends keyof Store>(field: Field) => {
101-
const storedValue = store[field]
102-
const cachedValue = cache[field]
103-
104-
if (typeof storedValue === 'function') {
105-
return storedValue
101+
if (typeof store[field] === 'function') {
102+
return store[field]
106103
}
107104

108-
if (!isEqual(storedValue, cachedValue)) {
105+
if (!isEqual(store[field], cache[field])) {
109106
cache[field] = structuredClone(store[field])
110107
}
111108

0 commit comments

Comments
 (0)