keyv 5.3.0 → 5.3.1

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
@@ -560,10 +560,14 @@ var Keyv = class extends event_manager_default {
560
560
  }
561
561
  return result;
562
562
  }
563
+ /**
564
+ * Set an item to the store
565
+ * @param {string | Array<KeyvEntry>} key the key to use. If you pass in an array of KeyvEntry it will set many items
566
+ * @param {Value} value the value of the key
567
+ * @param {number} [ttl] time to live in milliseconds
568
+ * @returns {boolean} if it sets then it will return a true. On failure will return false.
569
+ */
563
570
  async set(key, value, ttl) {
564
- if (Array.isArray(key)) {
565
- return this.setMany(key);
566
- }
567
571
  this.hooks.trigger("preSet" /* PRE_SET */, { key, value, ttl });
568
572
  const keyPrefixed = this._getKeyPrefix(key);
569
573
  if (ttl === void 0) {
package/dist/index.d.cts CHANGED
@@ -87,6 +87,11 @@ type KeyvStoreAdapter = {
87
87
  namespace?: string;
88
88
  get<Value>(key: string): Promise<StoredData<Value> | undefined>;
89
89
  set(key: string, value: any, ttl?: number): any;
90
+ setMany?(values: Array<{
91
+ key: string;
92
+ value: any;
93
+ ttl?: number;
94
+ }>): Promise<void>;
90
95
  delete(key: string): Promise<boolean>;
91
96
  clear(): Promise<void>;
92
97
  has?(key: string): Promise<boolean>;
@@ -94,7 +99,6 @@ type KeyvStoreAdapter = {
94
99
  getMany?<Value>(keys: string[]): Promise<Array<StoredData<Value | undefined>>>;
95
100
  disconnect?(): Promise<void>;
96
101
  deleteMany?(key: string[]): Promise<boolean>;
97
- setMany?(data: KeyvEntry[]): Promise<boolean[]>;
98
102
  iterator?<Value>(namespace?: string): AsyncGenerator<Array<string | Awaited<Value> | undefined>, void>;
99
103
  } & IEventEmitter;
100
104
  type KeyvOptions = {
@@ -264,7 +268,6 @@ declare class Keyv<GenericValue = any> extends EventManager {
264
268
  * @param {number} [ttl] time to live in milliseconds
265
269
  * @returns {boolean} if it sets then it will return a true. On failure will return false.
266
270
  */
267
- set<Value = GenericValue>(key: KeyvEntry[]): Promise<boolean[]>;
268
271
  set<Value = GenericValue>(key: string, value: Value, ttl?: number): Promise<boolean>;
269
272
  /**
270
273
  * Set many items to the store
package/dist/index.d.ts CHANGED
@@ -87,6 +87,11 @@ type KeyvStoreAdapter = {
87
87
  namespace?: string;
88
88
  get<Value>(key: string): Promise<StoredData<Value> | undefined>;
89
89
  set(key: string, value: any, ttl?: number): any;
90
+ setMany?(values: Array<{
91
+ key: string;
92
+ value: any;
93
+ ttl?: number;
94
+ }>): Promise<void>;
90
95
  delete(key: string): Promise<boolean>;
91
96
  clear(): Promise<void>;
92
97
  has?(key: string): Promise<boolean>;
@@ -94,7 +99,6 @@ type KeyvStoreAdapter = {
94
99
  getMany?<Value>(keys: string[]): Promise<Array<StoredData<Value | undefined>>>;
95
100
  disconnect?(): Promise<void>;
96
101
  deleteMany?(key: string[]): Promise<boolean>;
97
- setMany?(data: KeyvEntry[]): Promise<boolean[]>;
98
102
  iterator?<Value>(namespace?: string): AsyncGenerator<Array<string | Awaited<Value> | undefined>, void>;
99
103
  } & IEventEmitter;
100
104
  type KeyvOptions = {
@@ -264,7 +268,6 @@ declare class Keyv<GenericValue = any> extends EventManager {
264
268
  * @param {number} [ttl] time to live in milliseconds
265
269
  * @returns {boolean} if it sets then it will return a true. On failure will return false.
266
270
  */
267
- set<Value = GenericValue>(key: KeyvEntry[]): Promise<boolean[]>;
268
271
  set<Value = GenericValue>(key: string, value: Value, ttl?: number): Promise<boolean>;
269
272
  /**
270
273
  * Set many items to the store
package/dist/index.js CHANGED
@@ -534,10 +534,14 @@ var Keyv = class extends event_manager_default {
534
534
  }
535
535
  return result;
536
536
  }
537
+ /**
538
+ * Set an item to the store
539
+ * @param {string | Array<KeyvEntry>} key the key to use. If you pass in an array of KeyvEntry it will set many items
540
+ * @param {Value} value the value of the key
541
+ * @param {number} [ttl] time to live in milliseconds
542
+ * @returns {boolean} if it sets then it will return a true. On failure will return false.
543
+ */
537
544
  async set(key, value, ttl) {
538
- if (Array.isArray(key)) {
539
- return this.setMany(key);
540
- }
541
545
  this.hooks.trigger("preSet" /* PRE_SET */, { key, value, ttl });
542
546
  const keyPrefixed = this._getKeyPrefix(key);
543
547
  if (ttl === void 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keyv",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "Simple key-value storage with support for multiple backends",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -64,13 +64,13 @@
64
64
  "tsd": "^0.31.2",
65
65
  "vitest": "^3.0.7",
66
66
  "xo": "^0.60.0",
67
- "@keyv/compress-brotli": "^2.0.3",
68
67
  "@keyv/compress-gzip": "^2.0.2",
69
- "@keyv/memcache": "^2.0.1",
70
- "@keyv/compress-lz4": "^1.0.0",
68
+ "@keyv/compress-brotli": "^2.0.3",
71
69
  "@keyv/mongo": "^3.0.1",
72
- "@keyv/sqlite": "^4.0.1",
73
- "@keyv/test-suite": "^2.0.5"
70
+ "@keyv/compress-lz4": "^1.0.0",
71
+ "@keyv/test-suite": "^2.0.5",
72
+ "@keyv/memcache": "^2.0.1",
73
+ "@keyv/sqlite": "^4.0.1"
74
74
  },
75
75
  "tsd": {
76
76
  "directory": "test"