flat-cache 6.1.17 → 6.1.19
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/dist/index.cjs +28 -4
- package/dist/index.js +28 -4
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -190,10 +190,33 @@ var FlatCache = class extends import_hookified.Hookified {
|
|
|
190
190
|
if (import_node_fs.default.existsSync(pathToFile)) {
|
|
191
191
|
const data = import_node_fs.default.readFileSync(pathToFile, "utf8");
|
|
192
192
|
const items = this._parse(data);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
if (Array.isArray(items)) {
|
|
194
|
+
for (const item of items) {
|
|
195
|
+
if (item && typeof item === "object" && "key" in item) {
|
|
196
|
+
if (item.expires) {
|
|
197
|
+
this._cache.set(item.key, item.value, { expire: item.expires });
|
|
198
|
+
} else if (item.timestamp) {
|
|
199
|
+
this._cache.set(item.key, item.value, { expire: item.timestamp });
|
|
200
|
+
} else {
|
|
201
|
+
this._cache.set(item.key, item.value);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
for (const key of Object.keys(items)) {
|
|
207
|
+
const item = items[key];
|
|
208
|
+
if (item && typeof item === "object" && "key" in item) {
|
|
209
|
+
this._cache.set(item.key, item.value, {
|
|
210
|
+
expire: item.expires
|
|
211
|
+
});
|
|
212
|
+
} else {
|
|
213
|
+
if (item && typeof item === "object" && item.timestamp) {
|
|
214
|
+
this._cache.set(key, item, { expire: item.timestamp });
|
|
215
|
+
} else {
|
|
216
|
+
this._cache.set(key, item);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
197
220
|
}
|
|
198
221
|
this._changesSinceLastSave = true;
|
|
199
222
|
}
|
|
@@ -469,3 +492,4 @@ function clearAll(cacheDirectory) {
|
|
|
469
492
|
create,
|
|
470
493
|
createFromFile
|
|
471
494
|
});
|
|
495
|
+
/* v8 ignore next -- @preserve */
|
package/dist/index.js
CHANGED
|
@@ -150,10 +150,33 @@ var FlatCache = class extends Hookified {
|
|
|
150
150
|
if (fs.existsSync(pathToFile)) {
|
|
151
151
|
const data = fs.readFileSync(pathToFile, "utf8");
|
|
152
152
|
const items = this._parse(data);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
if (Array.isArray(items)) {
|
|
154
|
+
for (const item of items) {
|
|
155
|
+
if (item && typeof item === "object" && "key" in item) {
|
|
156
|
+
if (item.expires) {
|
|
157
|
+
this._cache.set(item.key, item.value, { expire: item.expires });
|
|
158
|
+
} else if (item.timestamp) {
|
|
159
|
+
this._cache.set(item.key, item.value, { expire: item.timestamp });
|
|
160
|
+
} else {
|
|
161
|
+
this._cache.set(item.key, item.value);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
for (const key of Object.keys(items)) {
|
|
167
|
+
const item = items[key];
|
|
168
|
+
if (item && typeof item === "object" && "key" in item) {
|
|
169
|
+
this._cache.set(item.key, item.value, {
|
|
170
|
+
expire: item.expires
|
|
171
|
+
});
|
|
172
|
+
} else {
|
|
173
|
+
if (item && typeof item === "object" && item.timestamp) {
|
|
174
|
+
this._cache.set(key, item, { expire: item.timestamp });
|
|
175
|
+
} else {
|
|
176
|
+
this._cache.set(key, item);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
157
180
|
}
|
|
158
181
|
this._changesSinceLastSave = true;
|
|
159
182
|
}
|
|
@@ -429,3 +452,4 @@ export {
|
|
|
429
452
|
createFromFile,
|
|
430
453
|
FlatCacheDefault as default
|
|
431
454
|
};
|
|
455
|
+
/* v8 ignore next -- @preserve */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flat-cache",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.19",
|
|
4
4
|
"description": "A simple key/value storage using files to persist the data",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -52,19 +52,19 @@
|
|
|
52
52
|
"file-system-cache"
|
|
53
53
|
],
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@biomejs/biome": "^2.
|
|
56
|
-
"@faker-js/faker": "^10.
|
|
57
|
-
"@types/node": "^24.
|
|
58
|
-
"@vitest/coverage-v8": "^
|
|
59
|
-
"rimraf": "^6.0
|
|
60
|
-
"tsup": "^8.5.
|
|
61
|
-
"typescript": "^5.9.
|
|
62
|
-
"vitest": "^
|
|
55
|
+
"@biomejs/biome": "^2.3.5",
|
|
56
|
+
"@faker-js/faker": "^10.1.0",
|
|
57
|
+
"@types/node": "^24.10.1",
|
|
58
|
+
"@vitest/coverage-v8": "^4.0.9",
|
|
59
|
+
"rimraf": "^6.1.0",
|
|
60
|
+
"tsup": "^8.5.1",
|
|
61
|
+
"typescript": "^5.9.3",
|
|
62
|
+
"vitest": "^4.0.9"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"flatted": "^3.3.3",
|
|
66
|
-
"hookified": "^1.
|
|
67
|
-
"cacheable": "^2.0
|
|
66
|
+
"hookified": "^1.13.0",
|
|
67
|
+
"cacheable": "^2.2.0"
|
|
68
68
|
},
|
|
69
69
|
"files": [
|
|
70
70
|
"dist",
|