Original zarr.Array to wrap
L0 decompressed chunk cache instance
Full path to the array (used for cache key generation)
Optional residency-probe / abort-signal / decode-origin accessors (see CachedArrayHooks).
Proxied zarr.Array with L0 caching enabled
const cache = new DecompressedChunkCache({ maxSize: 200 * 1024 * 1024 });
// Wrap array after opening
const rawArray = await zarr.open(location.resolve('positions'), { kind: 'array' });
const cachedArray = wrapWithCache(rawArray, cache, '/scene/points/positions');
// Use normally - getChunk() now checks L0 cache
const chunk = await cachedArray.getChunk([0, 1, 2]);
// First call: decompresses and caches
// Subsequent calls: returns from L0 cache instantly
Wrap a zarr.Array with L0 decompressed chunk caching.
The returned proxy intercepts
getChunk()calls:cache— joins that decode instead of starting another (the in-flight map lives on the DecompressedChunkCache, not on the proxy)getChunk(), caches result, returns dataREAD-ONLY CONTRACT: every caller — the miss that decoded a chunk, the waiters that joined that decode, and every later hit — receives the SAME buffer L0 holds, so no consumer may mutate a chunk it is handed. zarrita
get()(readArray) satisfies this by construction: it copies each chunk into its own freshly allocated output (setter.setFromChunk). A directgetChunk()caller must copy before writing. A decoded view that does not span its wholeArrayBuffer(e.g. an uncompressed chunk sliced out of a larger shard/archive buffer) is still copied for storage, so L0 never retains more bytes than it accounts for.Abort isolation: the shared decode runs under its own
AbortController, never under a caller's signal. Each caller races the decode against its own signal (the call'soptions.signal, elsehooks.getSignal()), and the decode is cancelled only once EVERY waiter has aborted. A decode that is not fully abandoned completes and is cached; so does an abandoned one that the cancellation could no longer stop.All other zarr.Array properties and methods pass through unchanged.