Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Nov 13, 2023
1 parent b662708 commit 204e073
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { useSyncExternalStore } = useSyncExternalStoreExports

const useAffectedDebugValue = (
state: object,
affected: WeakMap<object, unknown>
affected: WeakMap<object, unknown>,
) => {
const pathList = useRef<(string | number | symbol)[][]>()
useEffect(() => {
Expand Down Expand Up @@ -108,7 +108,7 @@ type Options = {
*/
export function useSnapshot<T extends object>(
proxyObject: T,
options?: Options
options?: Options,
): Snapshot<T> {
const notifyInSync = options?.sync
const lastSnapshot = useRef<Snapshot<T>>()
Expand All @@ -121,7 +121,7 @@ export function useSnapshot<T extends object>(
callback() // Note: do we really need this?
return unsub
},
[proxyObject, notifyInSync]
[proxyObject, notifyInSync],
),
() => {
const nextSnapshot = snapshot(proxyObject)
Expand All @@ -134,7 +134,7 @@ export function useSnapshot<T extends object>(
lastSnapshot.current,
nextSnapshot,
lastAffected.current,
new WeakMap()
new WeakMap(),
)
) {
// not changed
Expand All @@ -145,7 +145,7 @@ export function useSnapshot<T extends object>(
}
return nextSnapshot
},
() => snapshot(proxyObject)
() => snapshot(proxyObject),
)
inRender = false
const currAffected = new WeakMap()
Expand All @@ -162,6 +162,6 @@ export function useSnapshot<T extends object>(
currSnapshot,
currAffected,
proxyCache,
targetCache
targetCache,
)
}
12 changes: 6 additions & 6 deletions src/vanilla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const buildProxyFunction = (

createSnapshot: CreateSnapshot = <T extends object>(
target: T,
version: number
version: number,
): T => {
const cache = snapCache.get(target)
if (cache?.[0] === version) {
Expand All @@ -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,
Expand All @@ -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<T>
}
Expand Down Expand Up @@ -279,15 +279,15 @@ 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]
}
})
initializing = false
return proxyObject
}
},
) =>
[
// public functions
Expand Down Expand Up @@ -319,7 +319,7 @@ export function getVersion(proxyObject: unknown): number | undefined {
export function subscribe<T extends object>(
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) {
Expand Down
12 changes: 6 additions & 6 deletions tests/async.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ it.skipIf(typeof use === 'undefined')('delayed increment', async () => {
<Suspense fallback="loading">
<Counter />
</Suspense>
</StrictMode>
</StrictMode>,
)

await findByText('count: 0')
Expand Down Expand Up @@ -66,7 +66,7 @@ it.skipIf(typeof use === 'undefined')('delayed object', async () => {
<Suspense fallback="loading">
<Counter />
</Suspense>
</StrictMode>
</StrictMode>,
)

await findByText('text: none')
Expand All @@ -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 })),
)
}

Expand All @@ -104,7 +104,7 @@ it.skipIf(typeof use === 'undefined')(
<Suspense fallback="loading">
<Counter />
</Suspense>
</StrictMode>
</StrictMode>,
)

await findByText('loading')
Expand All @@ -120,7 +120,7 @@ it.skipIf(typeof use === 'undefined')(
getByText('text: counter')
getByText('count: 1')
})
}
},
)

it.skipIf(typeof use === 'undefined')('delayed falsy value', async () => {
Expand All @@ -144,7 +144,7 @@ it.skipIf(typeof use === 'undefined')('delayed falsy value', async () => {
<Suspense fallback="loading">
<Counter />
</Suspense>
</StrictMode>
</StrictMode>,
)

await findByText('value: true')
Expand Down

0 comments on commit 204e073

Please sign in to comment.