@zenweb/cache 4.1.2 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/cache.js +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cache.js
CHANGED
|
@@ -95,12 +95,13 @@ class Cache {
|
|
|
95
95
|
let _opt = Object.assign({ parse: true, decompress: true }, opt);
|
|
96
96
|
if (data) {
|
|
97
97
|
// 解压处理
|
|
98
|
-
|
|
98
|
+
let compressed = GZ_HEADER.equals(data.subarray(0, GZ_HEADER.length));
|
|
99
99
|
if (compressed) {
|
|
100
100
|
_getDebug('[%s] is compressed', key);
|
|
101
101
|
if (_opt.parse || _opt.decompress) {
|
|
102
102
|
_getDebug('[%s] decompress', key);
|
|
103
103
|
data = await decompress(data);
|
|
104
|
+
compressed = false;
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
// 解析处理
|
|
@@ -121,7 +122,7 @@ class Cache {
|
|
|
121
122
|
if ((_opt === null || _opt === void 0 ? void 0 : _opt.parse) !== false) {
|
|
122
123
|
return obj;
|
|
123
124
|
}
|
|
124
|
-
return new CacheResult(!opt.decompress
|
|
125
|
+
return new CacheResult(!opt.decompress, !opt.decompress && result.compressed || Buffer.from(result.data));
|
|
125
126
|
};
|
|
126
127
|
// 预刷新处理
|
|
127
128
|
const preRefresh = async () => {
|