MCPcopy
hub / github.com/protomaps/PMTiles / getDirectory

Method getDirectory

js/src/index.ts:683–712  ·  view source on GitHub ↗
(
    source: Source,
    offset: number,
    length: number,
    header: Header
  )

Source from the content-addressed store, hash-verified

681 }
682
683 async getDirectory(
684 source: Source,
685 offset: number,
686 length: number,
687 header: Header
688 ): Promise<Entry[]> {
689 const cacheKey = `${source.getKey()}|${
690 header.etag || ""
691 }|${offset}|${length}`;
692 const cacheValue = this.cache.get(cacheKey);
693 if (cacheValue) {
694 cacheValue.lastUsed = this.counter++;
695 const data = cacheValue.data;
696 return data as Entry[];
697 }
698
699 const directory = await getDirectory(
700 source,
701 this.decompress,
702 offset,
703 length,
704 header
705 );
706 this.cache.set(cacheKey, {
707 lastUsed: this.counter++,
708 data: directory,
709 });
710 this.prune();
711 return directory;
712 }
713
714 prune() {
715 if (this.cache.size > this.maxCacheEntries) {

Callers 3

v3.test.tsFile · 0.45
getZxyAttemptMethod · 0.45
ArchiveViewFunction · 0.45

Calls 4

pruneMethod · 0.95
getDirectoryFunction · 0.85
getKeyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected