保誠-保戶業務員媒合平台
Tomas
2022-05-19 957a1f10a06fdbb76f1a0ba94fe44126c613fee3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"use strict";
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
 
class Cache {
  constructor(compilation) {
    this.cache = compilation.getCache('TerserWebpackPlugin');
  }
 
  async get(cacheData) {
    // eslint-disable-next-line no-param-reassign
    cacheData.eTag = cacheData.eTag || Array.isArray(cacheData.inputSource) ? cacheData.inputSource.map(item => this.cache.getLazyHashedEtag(item)).reduce((previousValue, currentValue) => this.cache.mergeEtags(previousValue, currentValue)) : this.cache.getLazyHashedEtag(cacheData.inputSource);
    return this.cache.getPromise(cacheData.name, cacheData.eTag);
  }
 
  async store(cacheData) {
    let data;
 
    if (cacheData.target === 'comments') {
      data = cacheData.output;
    } else {
      data = {
        source: cacheData.source,
        extractedCommentsSource: cacheData.extractedCommentsSource,
        commentsFilename: cacheData.commentsFilename
      };
    }
 
    return this.cache.storePromise(cacheData.name, cacheData.eTag, data);
  }
 
}
 
exports.default = Cache;