keyv 5.3.3 → 5.3.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 +18 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -6
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -463,6 +463,7 @@ var Keyv = class extends event_manager_default {
|
|
|
463
463
|
_isValidStorageAdapter(store) {
|
|
464
464
|
return store instanceof Map || typeof store.get === "function" && typeof store.set === "function" && typeof store.delete === "function" && typeof store.clear === "function";
|
|
465
465
|
}
|
|
466
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
466
467
|
async get(key, options) {
|
|
467
468
|
const { store } = this.opts;
|
|
468
469
|
const isArray = Array.isArray(key);
|
|
@@ -552,14 +553,12 @@ var Keyv = class extends event_manager_default {
|
|
|
552
553
|
const data = { key, value, ttl };
|
|
553
554
|
this.hooks.trigger("preSet" /* PRE_SET */, data);
|
|
554
555
|
const keyPrefixed = this._getKeyPrefix(data.key);
|
|
555
|
-
|
|
556
|
-
data.ttl = this._ttl;
|
|
557
|
-
}
|
|
556
|
+
data.ttl ??= this._ttl;
|
|
558
557
|
if (data.ttl === 0) {
|
|
559
558
|
data.ttl = void 0;
|
|
560
559
|
}
|
|
561
560
|
const { store } = this.opts;
|
|
562
|
-
const expires = typeof data.ttl === "number" ? Date.now() + data.ttl :
|
|
561
|
+
const expires = typeof data.ttl === "number" ? Date.now() + data.ttl : void 0;
|
|
563
562
|
if (typeof data.value === "symbol") {
|
|
564
563
|
this.emit("error", "symbol cannot be serialized");
|
|
565
564
|
throw new Error("symbol cannot be serialized");
|
|
@@ -589,8 +588,21 @@ var Keyv = class extends event_manager_default {
|
|
|
589
588
|
let results = [];
|
|
590
589
|
try {
|
|
591
590
|
if (this._store.setMany !== void 0) {
|
|
592
|
-
|
|
593
|
-
|
|
591
|
+
const serializedEntries = await Promise.all(entries.map(async ({ key, value, ttl }) => {
|
|
592
|
+
ttl ??= this._ttl;
|
|
593
|
+
if (ttl === 0) {
|
|
594
|
+
ttl = void 0;
|
|
595
|
+
}
|
|
596
|
+
const expires = typeof ttl === "number" ? Date.now() + ttl : void 0;
|
|
597
|
+
if (typeof value === "symbol") {
|
|
598
|
+
this.emit("error", "symbol cannot be serialized");
|
|
599
|
+
throw new Error("symbol cannot be serialized");
|
|
600
|
+
}
|
|
601
|
+
const formattedValue = { value, expires };
|
|
602
|
+
const serializedValue = await this.serializeData(formattedValue);
|
|
603
|
+
return { key, value: serializedValue, ttl };
|
|
604
|
+
}));
|
|
605
|
+
results = await this._store.setMany(serializedEntries);
|
|
594
606
|
}
|
|
595
607
|
const promises = [];
|
|
596
608
|
for (const entry of entries) {
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -437,6 +437,7 @@ var Keyv = class extends event_manager_default {
|
|
|
437
437
|
_isValidStorageAdapter(store) {
|
|
438
438
|
return store instanceof Map || typeof store.get === "function" && typeof store.set === "function" && typeof store.delete === "function" && typeof store.clear === "function";
|
|
439
439
|
}
|
|
440
|
+
// eslint-disable-next-line @stylistic/max-len
|
|
440
441
|
async get(key, options) {
|
|
441
442
|
const { store } = this.opts;
|
|
442
443
|
const isArray = Array.isArray(key);
|
|
@@ -526,14 +527,12 @@ var Keyv = class extends event_manager_default {
|
|
|
526
527
|
const data = { key, value, ttl };
|
|
527
528
|
this.hooks.trigger("preSet" /* PRE_SET */, data);
|
|
528
529
|
const keyPrefixed = this._getKeyPrefix(data.key);
|
|
529
|
-
|
|
530
|
-
data.ttl = this._ttl;
|
|
531
|
-
}
|
|
530
|
+
data.ttl ??= this._ttl;
|
|
532
531
|
if (data.ttl === 0) {
|
|
533
532
|
data.ttl = void 0;
|
|
534
533
|
}
|
|
535
534
|
const { store } = this.opts;
|
|
536
|
-
const expires = typeof data.ttl === "number" ? Date.now() + data.ttl :
|
|
535
|
+
const expires = typeof data.ttl === "number" ? Date.now() + data.ttl : void 0;
|
|
537
536
|
if (typeof data.value === "symbol") {
|
|
538
537
|
this.emit("error", "symbol cannot be serialized");
|
|
539
538
|
throw new Error("symbol cannot be serialized");
|
|
@@ -563,8 +562,21 @@ var Keyv = class extends event_manager_default {
|
|
|
563
562
|
let results = [];
|
|
564
563
|
try {
|
|
565
564
|
if (this._store.setMany !== void 0) {
|
|
566
|
-
|
|
567
|
-
|
|
565
|
+
const serializedEntries = await Promise.all(entries.map(async ({ key, value, ttl }) => {
|
|
566
|
+
ttl ??= this._ttl;
|
|
567
|
+
if (ttl === 0) {
|
|
568
|
+
ttl = void 0;
|
|
569
|
+
}
|
|
570
|
+
const expires = typeof ttl === "number" ? Date.now() + ttl : void 0;
|
|
571
|
+
if (typeof value === "symbol") {
|
|
572
|
+
this.emit("error", "symbol cannot be serialized");
|
|
573
|
+
throw new Error("symbol cannot be serialized");
|
|
574
|
+
}
|
|
575
|
+
const formattedValue = { value, expires };
|
|
576
|
+
const serializedValue = await this.serializeData(formattedValue);
|
|
577
|
+
return { key, value: serializedValue, ttl };
|
|
578
|
+
}));
|
|
579
|
+
results = await this._store.setMany(serializedEntries);
|
|
568
580
|
}
|
|
569
581
|
const promises = [];
|
|
570
582
|
for (const entry of entries) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keyv",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.4",
|
|
4
4
|
"description": "Simple key-value storage with support for multiple backends",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
"@keyv/serialize": "^1.0.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@faker-js/faker": "^9.
|
|
61
|
-
"@vitest/coverage-v8": "^3.
|
|
60
|
+
"@faker-js/faker": "^9.8.0",
|
|
61
|
+
"@vitest/coverage-v8": "^3.2.3",
|
|
62
62
|
"rimraf": "^6.0.1",
|
|
63
63
|
"timekeeper": "^2.3.1",
|
|
64
|
-
"tsd": "^0.
|
|
65
|
-
"vitest": "^3.
|
|
66
|
-
"xo": "^
|
|
67
|
-
"@keyv/compress-
|
|
68
|
-
"@keyv/compress-
|
|
69
|
-
"@keyv/
|
|
64
|
+
"tsd": "^0.32.0",
|
|
65
|
+
"vitest": "^3.2.3",
|
|
66
|
+
"xo": "^1.1.0",
|
|
67
|
+
"@keyv/compress-brotli": "^2.0.4",
|
|
68
|
+
"@keyv/compress-gzip": "^2.0.3",
|
|
69
|
+
"@keyv/sqlite": "^4.0.4",
|
|
70
70
|
"@keyv/memcache": "^2.0.1",
|
|
71
|
-
"@keyv/
|
|
72
|
-
"@keyv/mongo": "^3.0.
|
|
73
|
-
"@keyv/
|
|
71
|
+
"@keyv/test-suite": "^2.0.7",
|
|
72
|
+
"@keyv/mongo": "^3.0.2",
|
|
73
|
+
"@keyv/compress-lz4": "^1.0.0"
|
|
74
74
|
},
|
|
75
75
|
"tsd": {
|
|
76
76
|
"directory": "test"
|