flat-cache 6.1.9 → 6.1.10
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 +4 -5
- package/dist/index.js +6 -7
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -170,7 +170,6 @@ var FlatCache = class extends import_hookified.Hookified {
|
|
|
170
170
|
* @param cacheId {String} the id of the cache, would also be used as the name of the file cache
|
|
171
171
|
* @param cacheDir {String} directory for the cache entry
|
|
172
172
|
*/
|
|
173
|
-
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
174
173
|
load(cacheId, cacheDir) {
|
|
175
174
|
try {
|
|
176
175
|
const filePath = import_node_path.default.resolve(`${cacheDir ?? this._cacheDir}/${cacheId ?? this._cacheId}`);
|
|
@@ -202,7 +201,7 @@ var FlatCache = class extends import_hookified.Hookified {
|
|
|
202
201
|
*/
|
|
203
202
|
all() {
|
|
204
203
|
const result = {};
|
|
205
|
-
const items =
|
|
204
|
+
const items = [...this._cache.items];
|
|
206
205
|
for (const item of items) {
|
|
207
206
|
result[item.key] = item.value;
|
|
208
207
|
}
|
|
@@ -214,7 +213,7 @@ var FlatCache = class extends import_hookified.Hookified {
|
|
|
214
213
|
* @returns {Array}
|
|
215
214
|
*/
|
|
216
215
|
get items() {
|
|
217
|
-
return
|
|
216
|
+
return [...this._cache.items];
|
|
218
217
|
}
|
|
219
218
|
/**
|
|
220
219
|
* Returns the path to the file where the cache is persisted
|
|
@@ -238,7 +237,7 @@ var FlatCache = class extends import_hookified.Hookified {
|
|
|
238
237
|
* @returns {Array}
|
|
239
238
|
*/
|
|
240
239
|
keys() {
|
|
241
|
-
return
|
|
240
|
+
return [...this._cache.keys];
|
|
242
241
|
}
|
|
243
242
|
/**
|
|
244
243
|
* (Legacy) set key method. This method will be deprecated in the future
|
|
@@ -319,7 +318,7 @@ var FlatCache = class extends import_hookified.Hookified {
|
|
|
319
318
|
try {
|
|
320
319
|
if (this._changesSinceLastSave || force) {
|
|
321
320
|
const filePath = this.cacheFilePath;
|
|
322
|
-
const items =
|
|
321
|
+
const items = [...this._cache.items];
|
|
323
322
|
const data = this._stringify(items);
|
|
324
323
|
if (!import_node_fs.default.existsSync(this._cacheDir)) {
|
|
325
324
|
import_node_fs.default.mkdirSync(this._cacheDir, { recursive: true });
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import path from "
|
|
3
|
-
import fs from "
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
import { CacheableMemory } from "cacheable";
|
|
5
5
|
import { parse, stringify } from "flatted";
|
|
6
6
|
import { Hookified } from "hookified";
|
|
@@ -130,7 +130,6 @@ var FlatCache = class extends Hookified {
|
|
|
130
130
|
* @param cacheId {String} the id of the cache, would also be used as the name of the file cache
|
|
131
131
|
* @param cacheDir {String} directory for the cache entry
|
|
132
132
|
*/
|
|
133
|
-
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
134
133
|
load(cacheId, cacheDir) {
|
|
135
134
|
try {
|
|
136
135
|
const filePath = path.resolve(`${cacheDir ?? this._cacheDir}/${cacheId ?? this._cacheId}`);
|
|
@@ -162,7 +161,7 @@ var FlatCache = class extends Hookified {
|
|
|
162
161
|
*/
|
|
163
162
|
all() {
|
|
164
163
|
const result = {};
|
|
165
|
-
const items =
|
|
164
|
+
const items = [...this._cache.items];
|
|
166
165
|
for (const item of items) {
|
|
167
166
|
result[item.key] = item.value;
|
|
168
167
|
}
|
|
@@ -174,7 +173,7 @@ var FlatCache = class extends Hookified {
|
|
|
174
173
|
* @returns {Array}
|
|
175
174
|
*/
|
|
176
175
|
get items() {
|
|
177
|
-
return
|
|
176
|
+
return [...this._cache.items];
|
|
178
177
|
}
|
|
179
178
|
/**
|
|
180
179
|
* Returns the path to the file where the cache is persisted
|
|
@@ -198,7 +197,7 @@ var FlatCache = class extends Hookified {
|
|
|
198
197
|
* @returns {Array}
|
|
199
198
|
*/
|
|
200
199
|
keys() {
|
|
201
|
-
return
|
|
200
|
+
return [...this._cache.keys];
|
|
202
201
|
}
|
|
203
202
|
/**
|
|
204
203
|
* (Legacy) set key method. This method will be deprecated in the future
|
|
@@ -279,7 +278,7 @@ var FlatCache = class extends Hookified {
|
|
|
279
278
|
try {
|
|
280
279
|
if (this._changesSinceLastSave || force) {
|
|
281
280
|
const filePath = this.cacheFilePath;
|
|
282
|
-
const items =
|
|
281
|
+
const items = [...this._cache.items];
|
|
283
282
|
const data = this._stringify(items);
|
|
284
283
|
if (!fs.existsSync(this._cacheDir)) {
|
|
285
284
|
fs.mkdirSync(this._cacheDir, { recursive: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flat-cache",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.10",
|
|
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,18 +52,18 @@
|
|
|
52
52
|
"file-system-cache"
|
|
53
53
|
],
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@types/node": "^22.15.
|
|
56
|
-
"@vitest/coverage-v8": "^3.
|
|
55
|
+
"@types/node": "^22.15.30",
|
|
56
|
+
"@vitest/coverage-v8": "^3.2.2",
|
|
57
57
|
"rimraf": "^6.0.1",
|
|
58
|
-
"tsup": "^8.
|
|
58
|
+
"tsup": "^8.5.0",
|
|
59
59
|
"typescript": "^5.8.3",
|
|
60
|
-
"vitest": "^3.
|
|
61
|
-
"xo": "^
|
|
60
|
+
"vitest": "^3.2.2",
|
|
61
|
+
"xo": "^1.1.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"flatted": "^3.3.3",
|
|
65
|
-
"hookified": "^1.
|
|
66
|
-
"cacheable": "^1.
|
|
65
|
+
"hookified": "^1.9.1",
|
|
66
|
+
"cacheable": "^1.10.0"
|
|
67
67
|
},
|
|
68
68
|
"files": [
|
|
69
69
|
"dist",
|