(
source: Source,
offset: number,
length: number,
header: Header
)
| 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) { |
no test coverage detected