simulate an async operation (#33)

This commit is contained in:
Sylvain Lesage 2024-11-08 22:23:35 +01:00 committed by GitHub
parent 6ec836dac5
commit cb1e965e02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,6 +5,7 @@ describe('cachedAsyncBuffer', () => {
it('caches slices of a file to avoid multiple reads', async () => {
const slice = vi.fn(async (start, end) => {
// Simulate an async slice operation
await new Promise(resolve => setTimeout(resolve, 10))
if (end === undefined) end = 1000
if (start < 0) start = Math.max(0, 1000 + start)
const buffer = new ArrayBuffer(end - start)