diff --git a/src/react.ts b/src/react.ts index 7f529fb6..5f3fe1b7 100644 --- a/src/react.ts +++ b/src/react.ts @@ -17,7 +17,7 @@ const { useSyncExternalStore } = useSyncExternalStoreExports const useAffectedDebugValue = ( state: object, - affected: WeakMap + affected: WeakMap, ) => { const pathList = useRef<(string | number | symbol)[][]>() useEffect(() => { @@ -108,7 +108,7 @@ type Options = { */ export function useSnapshot( proxyObject: T, - options?: Options + options?: Options, ): Snapshot { const notifyInSync = options?.sync const lastSnapshot = useRef>() @@ -121,7 +121,7 @@ export function useSnapshot( callback() // Note: do we really need this? return unsub }, - [proxyObject, notifyInSync] + [proxyObject, notifyInSync], ), () => { const nextSnapshot = snapshot(proxyObject) @@ -134,7 +134,7 @@ export function useSnapshot( lastSnapshot.current, nextSnapshot, lastAffected.current, - new WeakMap() + new WeakMap(), ) ) { // not changed @@ -145,7 +145,7 @@ export function useSnapshot( } return nextSnapshot }, - () => snapshot(proxyObject) + () => snapshot(proxyObject), ) inRender = false const currAffected = new WeakMap() @@ -162,6 +162,6 @@ export function useSnapshot( currSnapshot, currAffected, proxyCache, - targetCache + targetCache, ) } diff --git a/src/vanilla.ts b/src/vanilla.ts index bff2b11f..2ff50cc9 100644 --- a/src/vanilla.ts +++ b/src/vanilla.ts @@ -82,7 +82,7 @@ const buildProxyFunction = ( createSnapshot: CreateSnapshot = ( target: T, - version: number + version: number, ): T => { const cache = snapCache.get(target) if (cache?.[0] === version) { @@ -101,7 +101,7 @@ const buildProxyFunction = ( const value = Reflect.get(target, key) const { enumerable } = Reflect.getOwnPropertyDescriptor( target, - key + key, ) as PropertyDescriptor const desc: PropertyDescriptor = { value, @@ -114,7 +114,7 @@ const buildProxyFunction = ( markToTrack(value as object, false) // mark not to track } else if (proxyStateMap.has(value as object)) { const [target, ensureVersion] = proxyStateMap.get( - value as object + value as object, ) as ProxyState desc.value = createSnapshot(target, ensureVersion()) as Snapshot } @@ -279,7 +279,7 @@ const buildProxyFunction = ( Reflect.ownKeys(baseObject).forEach((key) => { const desc = Object.getOwnPropertyDescriptor( baseObject, - key + key, ) as PropertyDescriptor if ('value' in desc && desc.writable) { proxyObject[key as keyof T] = baseObject[key as keyof T] @@ -287,7 +287,7 @@ const buildProxyFunction = ( }) initializing = false return proxyObject - } + }, ) => [ // public functions @@ -319,7 +319,7 @@ export function getVersion(proxyObject: unknown): number | undefined { export function subscribe( proxyObject: T, callback: (ops: Op[]) => void, - notifyInSync?: boolean + notifyInSync?: boolean, ): () => void { const proxyState = proxyStateMap.get(proxyObject as object) if (import.meta.env?.MODE !== 'production' && !proxyState) { diff --git a/tests/async.test.tsx b/tests/async.test.tsx index b7c39e07..47554f2c 100644 --- a/tests/async.test.tsx +++ b/tests/async.test.tsx @@ -35,7 +35,7 @@ it.skipIf(typeof use === 'undefined')('delayed increment', async () => { - + , ) await findByText('count: 0') @@ -66,7 +66,7 @@ it.skipIf(typeof use === 'undefined')('delayed object', async () => { - + , ) await findByText('text: none') @@ -84,7 +84,7 @@ it.skipIf(typeof use === 'undefined')( }) const updateObject = () => { state.object = state.object.then((v: any) => - sleep(300).then(() => ({ ...v, count: v.count + 1 })) + sleep(300).then(() => ({ ...v, count: v.count + 1 })), ) } @@ -104,7 +104,7 @@ it.skipIf(typeof use === 'undefined')( - + , ) await findByText('loading') @@ -120,7 +120,7 @@ it.skipIf(typeof use === 'undefined')( getByText('text: counter') getByText('count: 1') }) - } + }, ) it.skipIf(typeof use === 'undefined')('delayed falsy value', async () => { @@ -144,7 +144,7 @@ it.skipIf(typeof use === 'undefined')('delayed falsy value', async () => { - + , ) await findByText('value: true')