file-entry-cache 10.1.1 → 10.1.4

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 CHANGED
@@ -170,7 +170,6 @@ var FileEntryCache = class {
170
170
  * @param {Buffer} buffer buffer to calculate hash on
171
171
  * @return {String} content hash digest
172
172
  */
173
- // eslint-disable-next-line @typescript-eslint/no-restricted-types
174
173
  getHash(buffer) {
175
174
  return import_node_crypto.default.createHash(this._hashAlgorithm).update(buffer).digest("hex");
176
175
  }
@@ -204,17 +203,17 @@ var FileEntryCache = class {
204
203
  return !import_node_path.default.isAbsolute(filePath);
205
204
  }
206
205
  /**
207
- * Delete the cache file from the disk
208
- * @method deleteCacheFile
209
- * @return {boolean} true if the file was deleted, false otherwise
210
- */
206
+ * Delete the cache file from the disk
207
+ * @method deleteCacheFile
208
+ * @return {boolean} true if the file was deleted, false otherwise
209
+ */
211
210
  deleteCacheFile() {
212
211
  return this._cache.removeCacheFile();
213
212
  }
214
213
  /**
215
- * Remove the cache from the file and clear the memory cache
216
- * @method destroy
217
- */
214
+ * Remove the cache from the file and clear the memory cache
215
+ * @method destroy
216
+ */
218
217
  destroy() {
219
218
  this._cache.destroy();
220
219
  }
@@ -225,10 +224,14 @@ var FileEntryCache = class {
225
224
  */
226
225
  removeEntry(filePath, options) {
227
226
  if (this.isRelativePath(filePath)) {
228
- filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory });
227
+ filePath = this.getAbsolutePath(filePath, {
228
+ currentWorkingDirectory: options?.currentWorkingDirectory
229
+ });
229
230
  this._cache.removeKey(this.createFileKey(filePath));
230
231
  }
231
- const key = this.createFileKey(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory });
232
+ const key = this.createFileKey(filePath, {
233
+ currentWorkingDirectory: options?.currentWorkingDirectory
234
+ });
232
235
  this._cache.removeKey(key);
233
236
  }
234
237
  /**
@@ -266,7 +269,6 @@ var FileEntryCache = class {
266
269
  * @param options - The options for getting the file descriptor
267
270
  * @returns The file descriptor
268
271
  */
269
- // eslint-disable-next-line complexity
270
272
  getFileDescriptor(filePath, options) {
271
273
  let fstat;
272
274
  const result = {
@@ -275,7 +277,9 @@ var FileEntryCache = class {
275
277
  meta: {}
276
278
  };
277
279
  result.meta = this._cache.getKey(result.key) ?? {};
278
- filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory });
280
+ filePath = this.getAbsolutePath(filePath, {
281
+ currentWorkingDirectory: options?.currentWorkingDirectory
282
+ });
279
283
  const useCheckSumValue = options?.useCheckSum ?? this._useCheckSum;
280
284
  const useModifiedTimeValue = options?.useModifiedTime ?? this._useModifiedTime;
281
285
  try {
@@ -329,7 +333,7 @@ var FileEntryCache = class {
329
333
  * @returns The file descriptors
330
334
  */
331
335
  normalizeEntries(files) {
332
- const result = new Array();
336
+ const result = [];
333
337
  if (files) {
334
338
  for (const file of files) {
335
339
  const fileDescriptor = this.getFileDescriptor(file);
@@ -377,7 +381,7 @@ var FileEntryCache = class {
377
381
  * @returns {string[]} The updated files
378
382
  */
379
383
  getUpdatedFiles(files) {
380
- const result = new Array();
384
+ const result = [];
381
385
  const fileDescriptors = this.normalizeEntries(files);
382
386
  for (const fileDescriptor of fileDescriptors) {
383
387
  if (fileDescriptor.changed) {
@@ -393,7 +397,7 @@ var FileEntryCache = class {
393
397
  * @returns {FileDescriptor[]} The not found files
394
398
  */
395
399
  getFileDescriptorsByPath(filePath) {
396
- const result = new Array();
400
+ const result = [];
397
401
  const keys = this._cache.keys();
398
402
  for (const key of keys) {
399
403
  const absolutePath = this.getAbsolutePath(filePath);
package/dist/index.d.cts CHANGED
@@ -122,15 +122,15 @@ declare class FileEntryCache {
122
122
  */
123
123
  isRelativePath(filePath: string): boolean;
124
124
  /**
125
- * Delete the cache file from the disk
126
- * @method deleteCacheFile
127
- * @return {boolean} true if the file was deleted, false otherwise
128
- */
125
+ * Delete the cache file from the disk
126
+ * @method deleteCacheFile
127
+ * @return {boolean} true if the file was deleted, false otherwise
128
+ */
129
129
  deleteCacheFile(): boolean;
130
130
  /**
131
- * Remove the cache from the file and clear the memory cache
132
- * @method destroy
133
- */
131
+ * Remove the cache from the file and clear the memory cache
132
+ * @method destroy
133
+ */
134
134
  destroy(): void;
135
135
  /**
136
136
  * Remove and Entry From the Cache
package/dist/index.d.ts CHANGED
@@ -122,15 +122,15 @@ declare class FileEntryCache {
122
122
  */
123
123
  isRelativePath(filePath: string): boolean;
124
124
  /**
125
- * Delete the cache file from the disk
126
- * @method deleteCacheFile
127
- * @return {boolean} true if the file was deleted, false otherwise
128
- */
125
+ * Delete the cache file from the disk
126
+ * @method deleteCacheFile
127
+ * @return {boolean} true if the file was deleted, false otherwise
128
+ */
129
129
  deleteCacheFile(): boolean;
130
130
  /**
131
- * Remove the cache from the file and clear the memory cache
132
- * @method destroy
133
- */
131
+ * Remove the cache from the file and clear the memory cache
132
+ * @method destroy
133
+ */
134
134
  destroy(): void;
135
135
  /**
136
136
  * Remove and Entry From the Cache
package/dist/index.js CHANGED
@@ -2,7 +2,10 @@
2
2
  import crypto from "crypto";
3
3
  import fs from "fs";
4
4
  import path from "path";
5
- import { FlatCache, createFromFile as createFlatCacheFile } from "flat-cache";
5
+ import {
6
+ createFromFile as createFlatCacheFile,
7
+ FlatCache
8
+ } from "flat-cache";
6
9
  function createFromFile(filePath, useCheckSum, currentWorkingDirectory) {
7
10
  const fname = path.basename(filePath);
8
11
  const directory = path.dirname(filePath);
@@ -133,7 +136,6 @@ var FileEntryCache = class {
133
136
  * @param {Buffer} buffer buffer to calculate hash on
134
137
  * @return {String} content hash digest
135
138
  */
136
- // eslint-disable-next-line @typescript-eslint/no-restricted-types
137
139
  getHash(buffer) {
138
140
  return crypto.createHash(this._hashAlgorithm).update(buffer).digest("hex");
139
141
  }
@@ -167,17 +169,17 @@ var FileEntryCache = class {
167
169
  return !path.isAbsolute(filePath);
168
170
  }
169
171
  /**
170
- * Delete the cache file from the disk
171
- * @method deleteCacheFile
172
- * @return {boolean} true if the file was deleted, false otherwise
173
- */
172
+ * Delete the cache file from the disk
173
+ * @method deleteCacheFile
174
+ * @return {boolean} true if the file was deleted, false otherwise
175
+ */
174
176
  deleteCacheFile() {
175
177
  return this._cache.removeCacheFile();
176
178
  }
177
179
  /**
178
- * Remove the cache from the file and clear the memory cache
179
- * @method destroy
180
- */
180
+ * Remove the cache from the file and clear the memory cache
181
+ * @method destroy
182
+ */
181
183
  destroy() {
182
184
  this._cache.destroy();
183
185
  }
@@ -188,10 +190,14 @@ var FileEntryCache = class {
188
190
  */
189
191
  removeEntry(filePath, options) {
190
192
  if (this.isRelativePath(filePath)) {
191
- filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory });
193
+ filePath = this.getAbsolutePath(filePath, {
194
+ currentWorkingDirectory: options?.currentWorkingDirectory
195
+ });
192
196
  this._cache.removeKey(this.createFileKey(filePath));
193
197
  }
194
- const key = this.createFileKey(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory });
198
+ const key = this.createFileKey(filePath, {
199
+ currentWorkingDirectory: options?.currentWorkingDirectory
200
+ });
195
201
  this._cache.removeKey(key);
196
202
  }
197
203
  /**
@@ -229,7 +235,6 @@ var FileEntryCache = class {
229
235
  * @param options - The options for getting the file descriptor
230
236
  * @returns The file descriptor
231
237
  */
232
- // eslint-disable-next-line complexity
233
238
  getFileDescriptor(filePath, options) {
234
239
  let fstat;
235
240
  const result = {
@@ -238,7 +243,9 @@ var FileEntryCache = class {
238
243
  meta: {}
239
244
  };
240
245
  result.meta = this._cache.getKey(result.key) ?? {};
241
- filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options?.currentWorkingDirectory });
246
+ filePath = this.getAbsolutePath(filePath, {
247
+ currentWorkingDirectory: options?.currentWorkingDirectory
248
+ });
242
249
  const useCheckSumValue = options?.useCheckSum ?? this._useCheckSum;
243
250
  const useModifiedTimeValue = options?.useModifiedTime ?? this._useModifiedTime;
244
251
  try {
@@ -292,7 +299,7 @@ var FileEntryCache = class {
292
299
  * @returns The file descriptors
293
300
  */
294
301
  normalizeEntries(files) {
295
- const result = new Array();
302
+ const result = [];
296
303
  if (files) {
297
304
  for (const file of files) {
298
305
  const fileDescriptor = this.getFileDescriptor(file);
@@ -340,7 +347,7 @@ var FileEntryCache = class {
340
347
  * @returns {string[]} The updated files
341
348
  */
342
349
  getUpdatedFiles(files) {
343
- const result = new Array();
350
+ const result = [];
344
351
  const fileDescriptors = this.normalizeEntries(files);
345
352
  for (const fileDescriptor of fileDescriptors) {
346
353
  if (fileDescriptor.changed) {
@@ -356,7 +363,7 @@ var FileEntryCache = class {
356
363
  * @returns {FileDescriptor[]} The not found files
357
364
  */
358
365
  getFileDescriptorsByPath(filePath) {
359
- const result = new Array();
366
+ const result = [];
360
367
  const keys = this._cache.keys();
361
368
  for (const key of keys) {
362
369
  const absolutePath = this.getAbsolutePath(filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-entry-cache",
3
- "version": "10.1.1",
3
+ "version": "10.1.4",
4
4
  "description": "A lightweight cache for file metadata, ideal for processes that work on a specific set of files and only need to reprocess files that have changed since the last run",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -29,16 +29,16 @@
29
29
  "cache"
30
30
  ],
31
31
  "devDependencies": {
32
- "@types/node": "^22.15.30",
33
- "@vitest/coverage-v8": "^3.2.2",
32
+ "@biomejs/biome": "^2.2.0",
33
+ "@types/node": "^24.3.0",
34
+ "@vitest/coverage-v8": "^3.2.4",
34
35
  "rimraf": "^6.0.1",
35
36
  "tsup": "^8.5.0",
36
- "typescript": "^5.8.3",
37
- "vitest": "^3.2.2",
38
- "xo": "^1.1.0"
37
+ "typescript": "^5.9.2",
38
+ "vitest": "^3.2.4"
39
39
  },
40
40
  "dependencies": {
41
- "flat-cache": "^6.1.10"
41
+ "flat-cache": "^6.1.13"
42
42
  },
43
43
  "files": [
44
44
  "dist",
@@ -47,8 +47,8 @@
47
47
  "scripts": {
48
48
  "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
49
49
  "prepublish": "pnpm build",
50
- "test": "xo --fix && vitest run --coverage",
51
- "test:ci": "xo && vitest run",
50
+ "test": "biome check --write && vitest run --coverage",
51
+ "test:ci": "biome check && vitest run --coverage",
52
52
  "clean": "rimraf ./dist ./coverage ./node_modules"
53
53
  }
54
54
  }