Files
bsky-social-app/src/state/persisted/storage-lock.ts
T
2026-08-31 14:08:34 -05:00

19 lines
470 B
TypeScript

import {type PersistedApi} from './types'
export function runWithPersistedStorageLock<T>({
operation,
}: {
operation: () => T | Promise<T>
}): Promise<T> {
try {
return Promise.resolve(operation())
} catch (error) {
return Promise.reject(
error instanceof Error
? error
: new Error('Persisted storage operation failed', {cause: error}),
)
}
}
runWithPersistedStorageLock satisfies PersistedApi['runWithPersistedStorageLock']