flat-cache 6.1.3 → 6.1.5

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/README.md CHANGED
@@ -107,7 +107,7 @@ In version 6 we attempted to keep as much as the functionality as possible which
107
107
 
108
108
  - `create(options?: FlatCacheOptions)` - Creates a new cache and will load the data from disk if it exists
109
109
  - `createFromFile(filePath, options?: FlatCacheOptions)` - Creates a new cache from a file
110
- - `clearByCacheId(cacheId: string, cacheDir?: string)` - Clears the cache by the cacheId
110
+ - `clearCacheById(cacheId: string, cacheDir?: string)` - Clears the cache by the cacheId
111
111
  - `clearAll(cacheDirectory?: string)` - Clears all the caches
112
112
 
113
113
 
package/dist/index.cjs CHANGED
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  FlatCache: () => FlatCache,
34
34
  FlatCacheEvents: () => FlatCacheEvents,
35
35
  clearAll: () => clearAll,
@@ -38,7 +38,7 @@ __export(src_exports, {
38
38
  createFromFile: () => createFromFile,
39
39
  default: () => FlatCacheDefault
40
40
  });
41
- module.exports = __toCommonJS(src_exports);
41
+ module.exports = __toCommonJS(index_exports);
42
42
  var import_node_path = __toESM(require("path"), 1);
43
43
  var import_node_fs = __toESM(require("fs"), 1);
44
44
  var import_cacheable = require("cacheable");
@@ -190,7 +190,7 @@ var FlatCache = class extends import_hookified.Hookified {
190
190
  const data = import_node_fs.default.readFileSync(pathToFile, "utf8");
191
191
  const items = this._parse(data);
192
192
  for (const key of Object.keys(items)) {
193
- this._cache.set(key, items[key]);
193
+ this._cache.set(items[key].key, items[key].value, { expire: items[key].expires });
194
194
  }
195
195
  this._changesSinceLastSave = true;
196
196
  }
@@ -319,7 +319,7 @@ var FlatCache = class extends import_hookified.Hookified {
319
319
  try {
320
320
  if (this._changesSinceLastSave || force) {
321
321
  const filePath = this.cacheFilePath;
322
- const items = this.all();
322
+ const items = Array.from(this._cache.items);
323
323
  const data = this._stringify(items);
324
324
  if (!import_node_fs.default.existsSync(this._cacheDir)) {
325
325
  import_node_fs.default.mkdirSync(this._cacheDir, { recursive: true });
package/dist/index.js CHANGED
@@ -150,7 +150,7 @@ var FlatCache = class extends Hookified {
150
150
  const data = fs.readFileSync(pathToFile, "utf8");
151
151
  const items = this._parse(data);
152
152
  for (const key of Object.keys(items)) {
153
- this._cache.set(key, items[key]);
153
+ this._cache.set(items[key].key, items[key].value, { expire: items[key].expires });
154
154
  }
155
155
  this._changesSinceLastSave = true;
156
156
  }
@@ -279,7 +279,7 @@ var FlatCache = class extends Hookified {
279
279
  try {
280
280
  if (this._changesSinceLastSave || force) {
281
281
  const filePath = this.cacheFilePath;
282
- const items = this.all();
282
+ const items = Array.from(this._cache.items);
283
283
  const data = this._stringify(items);
284
284
  if (!fs.existsSync(this._cacheDir)) {
285
285
  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",
3
+ "version": "6.1.5",
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.10.0",
56
- "@vitest/coverage-v8": "^2.1.6",
55
+ "@types/node": "^22.10.2",
56
+ "@vitest/coverage-v8": "^2.1.8",
57
57
  "rimraf": "^6.0.1",
58
58
  "tsup": "^8.3.5",
59
59
  "typescript": "^5.7.2",
60
- "vitest": "^2.1.6",
61
- "xo": "^0.59.3"
60
+ "vitest": "^2.1.8",
61
+ "xo": "^0.60.0"
62
62
  },
63
63
  "dependencies": {
64
- "cacheable": "^1.8.5",
65
64
  "flatted": "^3.3.2",
66
- "hookified": "^1.5.1"
65
+ "hookified": "^1.6.0",
66
+ "cacheable": "^1.8.7"
67
67
  },
68
68
  "files": [
69
69
  "dist",
@@ -71,6 +71,7 @@
71
71
  ],
72
72
  "scripts": {
73
73
  "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
74
+ "prepublish": "pnpm build",
74
75
  "test": "xo --fix && vitest run --coverage",
75
76
  "test:ci": "xo && vitest run",
76
77
  "clean": "rimraf ./dist ./coverage ./node_modules"