keyv-dir-store 0.0.1 → 0.0.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/README.md CHANGED
@@ -1,24 +1,34 @@
1
-
2
- # KeyvDIR
1
+ # Keyv Directory Store
3
2
 
4
3
  Store key into a file per value
5
4
 
6
- ## Store each value with CSV
5
+ ## Usages
7
6
 
8
7
  ```ts
8
+ // Default: Store each value with JSON in format "{value: ..., expires: ...}"
9
9
  new Keyv({
10
- store: new KeyvDirStore("cache/kv", { ext: "csv" }),
11
- serialize: ({ value }) => csvFormat(value),
12
- deserialize: (str) => ({ value: csvParse(str), expires: undefined }),
10
+ store: new KeyvDirStore(".cache/kv")
13
11
  });
14
- ```
15
12
 
16
- ## Store each value with YAML
13
+ // Store each value with CSV
14
+ new Keyv({
15
+ store: new KeyvDirStore(".cache/kv", { ext: ".csv" }),
16
+ serialize: ({ value }) => d3.csvFormat(value),
17
+ deserialize: (str) => ({ value: d3.csvParse(str), expires: undefined }),
18
+ });
17
19
 
18
- ```ts
20
+ // Store each value with YAML
19
21
  new Keyv({
20
- store: new KeyvDirStore("cache/kv", { ext: "yaml" }),
22
+ store: new KeyvDirStore(".cache/kv", { ext: ".json" }),
21
23
  serialize: ({ value }) => yaml.stringify(value),
22
24
  deserialize: (str) => ({ value: yaml.parse(str), expires: undefined }),
23
25
  });
24
- ```
26
+
27
+ // Store each value with JSON
28
+ new Keyv({
29
+ store: new KeyvDirStore(".cache/kv", { ext: ".json" }),
30
+ serialize: ({ value }) => JSON.stringify(value, null, 2),
31
+ deserialize: (str) => ({ value: JSON.parse(str), expires: undefined }),
32
+ });
33
+
34
+ ```
package/dist/index.js ADDED
@@ -0,0 +1,408 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getProtoOf = Object.getPrototypeOf;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
+
20
+ // node_modules/crypt/crypt.js
21
+ var require_crypt = __commonJS((exports, module) => {
22
+ (function() {
23
+ var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", crypt = {
24
+ rotl: function(n, b) {
25
+ return n << b | n >>> 32 - b;
26
+ },
27
+ rotr: function(n, b) {
28
+ return n << 32 - b | n >>> b;
29
+ },
30
+ endian: function(n) {
31
+ if (n.constructor == Number) {
32
+ return crypt.rotl(n, 8) & 16711935 | crypt.rotl(n, 24) & 4278255360;
33
+ }
34
+ for (var i = 0;i < n.length; i++)
35
+ n[i] = crypt.endian(n[i]);
36
+ return n;
37
+ },
38
+ randomBytes: function(n) {
39
+ for (var bytes = [];n > 0; n--)
40
+ bytes.push(Math.floor(Math.random() * 256));
41
+ return bytes;
42
+ },
43
+ bytesToWords: function(bytes) {
44
+ for (var words = [], i = 0, b = 0;i < bytes.length; i++, b += 8)
45
+ words[b >>> 5] |= bytes[i] << 24 - b % 32;
46
+ return words;
47
+ },
48
+ wordsToBytes: function(words) {
49
+ for (var bytes = [], b = 0;b < words.length * 32; b += 8)
50
+ bytes.push(words[b >>> 5] >>> 24 - b % 32 & 255);
51
+ return bytes;
52
+ },
53
+ bytesToHex: function(bytes) {
54
+ for (var hex = [], i = 0;i < bytes.length; i++) {
55
+ hex.push((bytes[i] >>> 4).toString(16));
56
+ hex.push((bytes[i] & 15).toString(16));
57
+ }
58
+ return hex.join("");
59
+ },
60
+ hexToBytes: function(hex) {
61
+ for (var bytes = [], c = 0;c < hex.length; c += 2)
62
+ bytes.push(parseInt(hex.substr(c, 2), 16));
63
+ return bytes;
64
+ },
65
+ bytesToBase64: function(bytes) {
66
+ for (var base64 = [], i = 0;i < bytes.length; i += 3) {
67
+ var triplet = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
68
+ for (var j = 0;j < 4; j++)
69
+ if (i * 8 + j * 6 <= bytes.length * 8)
70
+ base64.push(base64map.charAt(triplet >>> 6 * (3 - j) & 63));
71
+ else
72
+ base64.push("=");
73
+ }
74
+ return base64.join("");
75
+ },
76
+ base64ToBytes: function(base64) {
77
+ base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
78
+ for (var bytes = [], i = 0, imod4 = 0;i < base64.length; imod4 = ++i % 4) {
79
+ if (imod4 == 0)
80
+ continue;
81
+ bytes.push((base64map.indexOf(base64.charAt(i - 1)) & Math.pow(2, -2 * imod4 + 8) - 1) << imod4 * 2 | base64map.indexOf(base64.charAt(i)) >>> 6 - imod4 * 2);
82
+ }
83
+ return bytes;
84
+ }
85
+ };
86
+ module.exports = crypt;
87
+ })();
88
+ });
89
+
90
+ // node_modules/charenc/charenc.js
91
+ var require_charenc = __commonJS((exports, module) => {
92
+ var charenc = {
93
+ utf8: {
94
+ stringToBytes: function(str) {
95
+ return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
96
+ },
97
+ bytesToString: function(bytes) {
98
+ return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
99
+ }
100
+ },
101
+ bin: {
102
+ stringToBytes: function(str) {
103
+ for (var bytes = [], i = 0;i < str.length; i++)
104
+ bytes.push(str.charCodeAt(i) & 255);
105
+ return bytes;
106
+ },
107
+ bytesToString: function(bytes) {
108
+ for (var str = [], i = 0;i < bytes.length; i++)
109
+ str.push(String.fromCharCode(bytes[i]));
110
+ return str.join("");
111
+ }
112
+ }
113
+ };
114
+ module.exports = charenc;
115
+ });
116
+
117
+ // node_modules/is-buffer/index.js
118
+ var require_is_buffer = __commonJS((exports, module) => {
119
+ var isBuffer = function(obj) {
120
+ return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
121
+ };
122
+ var isSlowBuffer = function(obj) {
123
+ return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isBuffer(obj.slice(0, 0));
124
+ };
125
+ /*!
126
+ * Determine if an object is a Buffer
127
+ *
128
+ * @author Feross Aboukhadijeh <https://feross.org>
129
+ * @license MIT
130
+ */
131
+ module.exports = function(obj) {
132
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer);
133
+ };
134
+ });
135
+
136
+ // node_modules/md5/md5.js
137
+ var require_md5 = __commonJS((exports, module) => {
138
+ (function() {
139
+ var crypt = require_crypt(), utf8 = require_charenc().utf8, isBuffer = require_is_buffer(), bin = require_charenc().bin, md5 = function(message, options) {
140
+ if (message.constructor == String)
141
+ if (options && options.encoding === "binary")
142
+ message = bin.stringToBytes(message);
143
+ else
144
+ message = utf8.stringToBytes(message);
145
+ else if (isBuffer(message))
146
+ message = Array.prototype.slice.call(message, 0);
147
+ else if (!Array.isArray(message) && message.constructor !== Uint8Array)
148
+ message = message.toString();
149
+ var m = crypt.bytesToWords(message), l = message.length * 8, a = 1732584193, b = -271733879, c = -1732584194, d = 271733878;
150
+ for (var i = 0;i < m.length; i++) {
151
+ m[i] = (m[i] << 8 | m[i] >>> 24) & 16711935 | (m[i] << 24 | m[i] >>> 8) & 4278255360;
152
+ }
153
+ m[l >>> 5] |= 128 << l % 32;
154
+ m[(l + 64 >>> 9 << 4) + 14] = l;
155
+ var { _ff: FF, _gg: GG, _hh: HH, _ii: II } = md5;
156
+ for (var i = 0;i < m.length; i += 16) {
157
+ var aa = a, bb = b, cc = c, dd = d;
158
+ a = FF(a, b, c, d, m[i + 0], 7, -680876936);
159
+ d = FF(d, a, b, c, m[i + 1], 12, -389564586);
160
+ c = FF(c, d, a, b, m[i + 2], 17, 606105819);
161
+ b = FF(b, c, d, a, m[i + 3], 22, -1044525330);
162
+ a = FF(a, b, c, d, m[i + 4], 7, -176418897);
163
+ d = FF(d, a, b, c, m[i + 5], 12, 1200080426);
164
+ c = FF(c, d, a, b, m[i + 6], 17, -1473231341);
165
+ b = FF(b, c, d, a, m[i + 7], 22, -45705983);
166
+ a = FF(a, b, c, d, m[i + 8], 7, 1770035416);
167
+ d = FF(d, a, b, c, m[i + 9], 12, -1958414417);
168
+ c = FF(c, d, a, b, m[i + 10], 17, -42063);
169
+ b = FF(b, c, d, a, m[i + 11], 22, -1990404162);
170
+ a = FF(a, b, c, d, m[i + 12], 7, 1804603682);
171
+ d = FF(d, a, b, c, m[i + 13], 12, -40341101);
172
+ c = FF(c, d, a, b, m[i + 14], 17, -1502002290);
173
+ b = FF(b, c, d, a, m[i + 15], 22, 1236535329);
174
+ a = GG(a, b, c, d, m[i + 1], 5, -165796510);
175
+ d = GG(d, a, b, c, m[i + 6], 9, -1069501632);
176
+ c = GG(c, d, a, b, m[i + 11], 14, 643717713);
177
+ b = GG(b, c, d, a, m[i + 0], 20, -373897302);
178
+ a = GG(a, b, c, d, m[i + 5], 5, -701558691);
179
+ d = GG(d, a, b, c, m[i + 10], 9, 38016083);
180
+ c = GG(c, d, a, b, m[i + 15], 14, -660478335);
181
+ b = GG(b, c, d, a, m[i + 4], 20, -405537848);
182
+ a = GG(a, b, c, d, m[i + 9], 5, 568446438);
183
+ d = GG(d, a, b, c, m[i + 14], 9, -1019803690);
184
+ c = GG(c, d, a, b, m[i + 3], 14, -187363961);
185
+ b = GG(b, c, d, a, m[i + 8], 20, 1163531501);
186
+ a = GG(a, b, c, d, m[i + 13], 5, -1444681467);
187
+ d = GG(d, a, b, c, m[i + 2], 9, -51403784);
188
+ c = GG(c, d, a, b, m[i + 7], 14, 1735328473);
189
+ b = GG(b, c, d, a, m[i + 12], 20, -1926607734);
190
+ a = HH(a, b, c, d, m[i + 5], 4, -378558);
191
+ d = HH(d, a, b, c, m[i + 8], 11, -2022574463);
192
+ c = HH(c, d, a, b, m[i + 11], 16, 1839030562);
193
+ b = HH(b, c, d, a, m[i + 14], 23, -35309556);
194
+ a = HH(a, b, c, d, m[i + 1], 4, -1530992060);
195
+ d = HH(d, a, b, c, m[i + 4], 11, 1272893353);
196
+ c = HH(c, d, a, b, m[i + 7], 16, -155497632);
197
+ b = HH(b, c, d, a, m[i + 10], 23, -1094730640);
198
+ a = HH(a, b, c, d, m[i + 13], 4, 681279174);
199
+ d = HH(d, a, b, c, m[i + 0], 11, -358537222);
200
+ c = HH(c, d, a, b, m[i + 3], 16, -722521979);
201
+ b = HH(b, c, d, a, m[i + 6], 23, 76029189);
202
+ a = HH(a, b, c, d, m[i + 9], 4, -640364487);
203
+ d = HH(d, a, b, c, m[i + 12], 11, -421815835);
204
+ c = HH(c, d, a, b, m[i + 15], 16, 530742520);
205
+ b = HH(b, c, d, a, m[i + 2], 23, -995338651);
206
+ a = II(a, b, c, d, m[i + 0], 6, -198630844);
207
+ d = II(d, a, b, c, m[i + 7], 10, 1126891415);
208
+ c = II(c, d, a, b, m[i + 14], 15, -1416354905);
209
+ b = II(b, c, d, a, m[i + 5], 21, -57434055);
210
+ a = II(a, b, c, d, m[i + 12], 6, 1700485571);
211
+ d = II(d, a, b, c, m[i + 3], 10, -1894986606);
212
+ c = II(c, d, a, b, m[i + 10], 15, -1051523);
213
+ b = II(b, c, d, a, m[i + 1], 21, -2054922799);
214
+ a = II(a, b, c, d, m[i + 8], 6, 1873313359);
215
+ d = II(d, a, b, c, m[i + 15], 10, -30611744);
216
+ c = II(c, d, a, b, m[i + 6], 15, -1560198380);
217
+ b = II(b, c, d, a, m[i + 13], 21, 1309151649);
218
+ a = II(a, b, c, d, m[i + 4], 6, -145523070);
219
+ d = II(d, a, b, c, m[i + 11], 10, -1120210379);
220
+ c = II(c, d, a, b, m[i + 2], 15, 718787259);
221
+ b = II(b, c, d, a, m[i + 9], 21, -343485551);
222
+ a = a + aa >>> 0;
223
+ b = b + bb >>> 0;
224
+ c = c + cc >>> 0;
225
+ d = d + dd >>> 0;
226
+ }
227
+ return crypt.endian([a, b, c, d]);
228
+ };
229
+ md5._ff = function(a, b, c, d, x, s, t) {
230
+ var n = a + (b & c | ~b & d) + (x >>> 0) + t;
231
+ return (n << s | n >>> 32 - s) + b;
232
+ };
233
+ md5._gg = function(a, b, c, d, x, s, t) {
234
+ var n = a + (b & d | c & ~d) + (x >>> 0) + t;
235
+ return (n << s | n >>> 32 - s) + b;
236
+ };
237
+ md5._hh = function(a, b, c, d, x, s, t) {
238
+ var n = a + (b ^ c ^ d) + (x >>> 0) + t;
239
+ return (n << s | n >>> 32 - s) + b;
240
+ };
241
+ md5._ii = function(a, b, c, d, x, s, t) {
242
+ var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
243
+ return (n << s | n >>> 32 - s) + b;
244
+ };
245
+ md5._blocksize = 16;
246
+ md5._digestsize = 16;
247
+ module.exports = function(message, options) {
248
+ if (message === undefined || message === null)
249
+ throw new Error("Illegal argument " + message);
250
+ var digestbytes = crypt.wordsToBytes(md5(message, options));
251
+ return options && options.asBytes ? digestbytes : options && options.asString ? bin.bytesToString(digestbytes) : crypt.bytesToHex(digestbytes);
252
+ };
253
+ })();
254
+ });
255
+
256
+ // node_modules/truncate-utf8-bytes/lib/truncate.js
257
+ var require_truncate = __commonJS((exports, module) => {
258
+ var isHighSurrogate = function(codePoint) {
259
+ return codePoint >= 55296 && codePoint <= 56319;
260
+ };
261
+ var isLowSurrogate = function(codePoint) {
262
+ return codePoint >= 56320 && codePoint <= 57343;
263
+ };
264
+ module.exports = function truncate(getLength, string, byteLength) {
265
+ if (typeof string !== "string") {
266
+ throw new Error("Input must be string");
267
+ }
268
+ var charLength = string.length;
269
+ var curByteLength = 0;
270
+ var codePoint;
271
+ var segment;
272
+ for (var i = 0;i < charLength; i += 1) {
273
+ codePoint = string.charCodeAt(i);
274
+ segment = string[i];
275
+ if (isHighSurrogate(codePoint) && isLowSurrogate(string.charCodeAt(i + 1))) {
276
+ i += 1;
277
+ segment += string[i];
278
+ }
279
+ curByteLength += getLength(segment);
280
+ if (curByteLength === byteLength) {
281
+ return string.slice(0, i + 1);
282
+ } else if (curByteLength > byteLength) {
283
+ return string.slice(0, i - segment.length + 1);
284
+ }
285
+ }
286
+ return string;
287
+ };
288
+ });
289
+
290
+ // node_modules/truncate-utf8-bytes/index.js
291
+ var require_truncate_utf8_bytes = __commonJS((exports, module) => {
292
+ var truncate = require_truncate();
293
+ var getLength = Buffer.byteLength.bind(Buffer);
294
+ module.exports = truncate.bind(null, getLength);
295
+ });
296
+
297
+ // node_modules/sanitize-filename/index.js
298
+ var require_sanitize_filename = __commonJS((exports, module) => {
299
+ var sanitize = function(input, replacement) {
300
+ if (typeof input !== "string") {
301
+ throw new Error("Input must be string");
302
+ }
303
+ var sanitized = input.replace(illegalRe, replacement).replace(controlRe, replacement).replace(reservedRe, replacement).replace(windowsReservedRe, replacement).replace(windowsTrailingRe, replacement);
304
+ return truncate(sanitized, 255);
305
+ };
306
+ var truncate = require_truncate_utf8_bytes();
307
+ var illegalRe = /[\/\?<>\\:\*\|"]/g;
308
+ var controlRe = /[\x00-\x1f\x80-\x9f]/g;
309
+ var reservedRe = /^\.+$/;
310
+ var windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
311
+ var windowsTrailingRe = /[\. ]+$/;
312
+ module.exports = function(input, options) {
313
+ var replacement = options && options.replacement || "";
314
+ var output = sanitize(input, replacement);
315
+ if (replacement === "") {
316
+ return output;
317
+ }
318
+ return sanitize(output, "");
319
+ };
320
+ });
321
+
322
+ // index.ts
323
+ var import_md5 = __toESM(require_md5(), 1);
324
+ var import_sanitize_filename = __toESM(require_sanitize_filename(), 1);
325
+ import {mkdir, readFile, rm, stat, utimes, writeFile} from "fs/promises";
326
+ import path from "path";
327
+
328
+ class KeyvDirStore {
329
+ #dir;
330
+ #cache;
331
+ #ready;
332
+ #path;
333
+ ext = ".json";
334
+ constructor(dir, {
335
+ cache = new Map,
336
+ path: path2,
337
+ ext
338
+ } = {}) {
339
+ this.#ready = mkdir(dir, { recursive: true });
340
+ this.#cache = cache;
341
+ this.#dir = dir;
342
+ this.#path = path2 ?? this.#defaultPath;
343
+ this.ext = ext ?? this.ext;
344
+ }
345
+ #defaultPath(key) {
346
+ const readableName = import_sanitize_filename.default(key).slice(4, 16);
347
+ const hashName = import_md5.default(this.#dir + key).slice(0, 16);
348
+ const name = readableName + "-" + hashName + this.ext;
349
+ return path.join(this.#dir, name);
350
+ }
351
+ async get(key) {
352
+ const cached = this.#cache.get(key);
353
+ if (cached) {
354
+ if (cached.expires && cached.expires < Date.now()) {
355
+ await this.delete(key);
356
+ } else {
357
+ return cached.value;
358
+ }
359
+ }
360
+ const stats = await stat(this.#path(key)).catch(() => null);
361
+ if (!stats)
362
+ return;
363
+ const expires = +stats.mtime;
364
+ if (expires !== 0) {
365
+ const expired = +stats.mtime < +Date.now();
366
+ if (expired) {
367
+ await this.delete(key);
368
+ return;
369
+ }
370
+ }
371
+ return await readFile(this.#path(key), "utf8").catch(() => {
372
+ return;
373
+ });
374
+ }
375
+ async set(key, value, ttl) {
376
+ if (!value)
377
+ return await this.delete(key);
378
+ const expires = ttl ? Date.now() + ttl : 0;
379
+ this.#cache.set(key, { value, expires });
380
+ await this.#ready;
381
+ await writeFile(this.#path(key), value);
382
+ await utimes(this.#path(key), +new Date, new Date(expires ?? 0));
383
+ return true;
384
+ }
385
+ async delete(key) {
386
+ this.#cache.delete(key);
387
+ await rm(this.#path(key), { force: true });
388
+ return true;
389
+ }
390
+ async clear() {
391
+ await rm(this.#dir, { recursive: true }).catch(() => {
392
+ return;
393
+ });
394
+ await mkdir(this.#dir, { recursive: true });
395
+ }
396
+ async has(key) {
397
+ return await this.get(key) !== undefined;
398
+ }
399
+ static serialize({ value }) {
400
+ return JSON.stringify(value, null, 2);
401
+ }
402
+ static deserialize(str) {
403
+ return { value: JSON.parse(str), expires: undefined };
404
+ }
405
+ }
406
+ export {
407
+ KeyvDirStore
408
+ };
package/index.test.ts CHANGED
@@ -4,7 +4,7 @@ import { KeyvDirStore } from ".";
4
4
  it("KeyvDirStore works", async () => {
5
5
  // store test
6
6
  const kv = new Keyv<number | string | { obj: boolean }>({
7
- store: new KeyvDirStore("cache/test1"),
7
+ store: new KeyvDirStore(".cache/test1"),
8
8
  deserialize: KeyvDirStore.deserialize,
9
9
  serialize: KeyvDirStore.serialize,
10
10
  });
@@ -20,7 +20,7 @@ it("KeyvDirStore works", async () => {
20
20
 
21
21
  // new instance with no cache Obj, to test file cache
22
22
  const kv2 = new Keyv<number | string | { obj: boolean }>({
23
- store: new KeyvDirStore("cache/test1"),
23
+ store: new KeyvDirStore(".cache/test1"),
24
24
  deserialize: KeyvDirStore.deserialize,
25
25
  serialize: KeyvDirStore.serialize,
26
26
  });
@@ -32,7 +32,7 @@ it("KeyvDirStore works", async () => {
32
32
  it("KeyvDirStore works with only store", async () => {
33
33
  // store test
34
34
  const kv = new Keyv<number | string | { obj: boolean }>({
35
- store: new KeyvDirStore("cache/test2"),
35
+ store: new KeyvDirStore(".cache/test2"),
36
36
  });
37
37
  await kv.clear();
38
38
  await kv.set("a", 1234, -86400e3); // already expired
@@ -46,7 +46,7 @@ it("KeyvDirStore works with only store", async () => {
46
46
 
47
47
  // new instance with no cache Obj, to test file cache
48
48
  const kv2 = new Keyv<number | string | { obj: boolean }>({
49
- store: new KeyvDirStore("cache/test2"),
49
+ store: new KeyvDirStore(".cache/test2"),
50
50
  });
51
51
  expect(await kv2.get("a")).toEqual(undefined); // will delete file before get
52
52
  expect(await kv2.get("b")).toEqual(1234);
package/index.ts CHANGED
@@ -1,12 +1,8 @@
1
- import { stat } from "fs/promises";
2
- import { writeFile } from "fs/promises";
3
- import { rm } from "fs/promises";
4
- import { readFile, mkdir } from "fs/promises";
5
- import { type default as Keyv, type DeserializedData } from "keyv";
1
+ import { mkdir, readFile, rm, stat, utimes, writeFile } from "node:fs/promises";
2
+ import type { DeserializedData, default as Keyv } from "keyv";
6
3
  import md5 from "md5";
7
- import sanitizeFilename from "sanitize-filename";
8
4
  import path from "path";
9
- import { utimes } from "fs/promises";
5
+ import sanitizeFilename from "sanitize-filename";
10
6
  type Value = any;
11
7
  type CacheMap<Value> = Map<string, DeserializedData<Value>>;
12
8
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keyv-dir-store",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "author": "snomiao <snomiao@gmail.com>",
5
5
  "type": "module",
6
6
  "exports": {
@@ -13,10 +13,16 @@
13
13
  "dist"
14
14
  ],
15
15
  "scripts": {
16
- "build": "bun build index.ts --outdir=dist",
16
+ "build": "bun build index.ts --outdir=dist --target=bun",
17
+ "prerelease": "bun run build && bun run test",
17
18
  "release": "bunx standard-version && git push --follow-tags && npm publish",
18
19
  "test": "bun test"
19
20
  },
21
+ "dependencies": {
22
+ "@types/node": "^20.14.2",
23
+ "md5": "^2.3.0",
24
+ "sanitize-filename": "^1.6.3"
25
+ },
20
26
  "devDependencies": {
21
27
  "@types/bun": "^1.1.3",
22
28
  "@types/jest": "^29.5.12",
@@ -25,9 +31,5 @@
25
31
  },
26
32
  "peerDependencies": {
27
33
  "keyv": "^4.5.4"
28
- },
29
- "dependencies": {
30
- "md5": "^2.3.0",
31
- "sanitize-filename": "^1.6.3"
32
34
  }
33
35
  }