(source: Source)
| 762 | } |
| 763 | |
| 764 | async getHeader(source: Source): Promise<Header> { |
| 765 | const cacheKey = source.getKey(); |
| 766 | const cacheValue = this.cache.get(cacheKey); |
| 767 | if (cacheValue) { |
| 768 | cacheValue.lastUsed = this.counter++; |
| 769 | const data = await cacheValue.data; |
| 770 | return data as Header; |
| 771 | } |
| 772 | |
| 773 | const p = new Promise<Header>((resolve, reject) => { |
| 774 | getHeaderAndRoot(source, this.decompress) |
| 775 | .then((res) => { |
| 776 | if (res[1]) { |
| 777 | this.cache.set(res[1][0], { |
| 778 | lastUsed: this.counter++, |
| 779 | data: Promise.resolve(res[1][2]), |
| 780 | }); |
| 781 | } |
| 782 | resolve(res[0]); |
| 783 | this.prune(); |
| 784 | }) |
| 785 | .catch((e) => { |
| 786 | reject(e); |
| 787 | }); |
| 788 | }); |
| 789 | this.cache.set(cacheKey, { lastUsed: this.counter++, data: p }); |
| 790 | return p; |
| 791 | } |
| 792 | |
| 793 | async getDirectory( |
| 794 | source: Source, |
no test coverage detected