mirror of
https://github.com/asadbek064/hyparquet.git
synced 2026-01-01 01:36:38 +00:00
Fix cached AsyncBuffer for urls only
This commit is contained in:
parent
447dab35be
commit
39f8c184a4
2
demo/bundle.min.js
vendored
2
demo/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -57,11 +57,16 @@ export function parquetQueryWorker({
|
||||
* Convert AsyncBufferFrom to AsyncBuffer.
|
||||
*/
|
||||
export async function asyncBufferFrom(from: AsyncBufferFrom): Promise<AsyncBuffer> {
|
||||
const key = JSON.stringify(from)
|
||||
const cached = cache.get(key)
|
||||
if (cached) return cached
|
||||
const asyncBuffer = 'url' in from ? asyncBufferFromUrl(from.url, from.byteLength) : from.file.arrayBuffer()
|
||||
cache.set(key, asyncBuffer.then(cachedAsyncBuffer))
|
||||
return asyncBuffer
|
||||
if ('url' in from) {
|
||||
// Cached asyncBuffer for urls only
|
||||
const key = JSON.stringify(from)
|
||||
const cached = cache.get(key)
|
||||
if (cached) return cached
|
||||
const asyncBuffer = asyncBufferFromUrl(from.url, from.byteLength).then(cachedAsyncBuffer)
|
||||
cache.set(key, asyncBuffer)
|
||||
return asyncBuffer
|
||||
} else {
|
||||
return from.file.arrayBuffer()
|
||||
}
|
||||
}
|
||||
const cache = new Map<string, Promise<AsyncBuffer>>()
|
||||
|
||||
2
demo/workers/worker.min.js
vendored
2
demo/workers/worker.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user