keyv 5.1.0 → 5.1.2
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 +8 -0
- package/dist/index.cjs +24 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +24 -0
- package/package.json +98 -94
package/README.md
CHANGED
|
@@ -221,6 +221,7 @@ The official storage adapters are covered by [over 150 integration tests](https:
|
|
|
221
221
|
Database | Adapter | Native TTL
|
|
222
222
|
---|---|---
|
|
223
223
|
Redis | [@keyv/redis](https://github.com/jaredwray/keyv/tree/master/packages/redis) | Yes
|
|
224
|
+
Valkey | [@keyv/valkey](https://github.com/jaredwray/keyv/tree/master/packages/valkey) | Yes
|
|
224
225
|
MongoDB | [@keyv/mongo](https://github.com/jaredwray/keyv/tree/master/packages/mongo) | Yes
|
|
225
226
|
SQLite | [@keyv/sqlite](https://github.com/jaredwray/keyv/tree/master/packages/sqlite) | No
|
|
226
227
|
PostgreSQL | [@keyv/postgres](https://github.com/jaredwray/keyv/tree/master/packages/postgres) | No
|
|
@@ -356,6 +357,13 @@ The connection string URI.
|
|
|
356
357
|
|
|
357
358
|
Merged into the options object as options.uri.
|
|
358
359
|
|
|
360
|
+
### .namespace
|
|
361
|
+
|
|
362
|
+
Type: `String`
|
|
363
|
+
Default: `'keyv'`
|
|
364
|
+
|
|
365
|
+
This is the namespace for the current instance. When you set it it will set it also on the storage adapter. This is the preferred way to set the namespace over `.opts.namespace`.
|
|
366
|
+
|
|
359
367
|
### options
|
|
360
368
|
|
|
361
369
|
Type: `Object`
|
package/dist/index.cjs
CHANGED
|
@@ -68,6 +68,13 @@ var EventManager = class {
|
|
|
68
68
|
this._eventListeners.delete(event);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
once(event, listener) {
|
|
72
|
+
const onceListener = (...arguments_) => {
|
|
73
|
+
listener(...arguments_);
|
|
74
|
+
this.off(event, onceListener);
|
|
75
|
+
};
|
|
76
|
+
this.on(event, onceListener);
|
|
77
|
+
}
|
|
71
78
|
// Emit an event
|
|
72
79
|
emit(event, ...arguments_) {
|
|
73
80
|
const listeners = this._eventListeners.get(event);
|
|
@@ -275,6 +282,23 @@ var Keyv = class extends event_manager_default {
|
|
|
275
282
|
this.stats.enabled = this.opts.stats;
|
|
276
283
|
}
|
|
277
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Get the current namespace.
|
|
287
|
+
* @returns {string | undefined} The current namespace.
|
|
288
|
+
*/
|
|
289
|
+
get namespace() {
|
|
290
|
+
return this.opts.namespace;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Set the current namespace.
|
|
294
|
+
* @param {string | undefined} namespace The namespace to set.
|
|
295
|
+
*/
|
|
296
|
+
set namespace(namespace) {
|
|
297
|
+
this.opts.namespace = namespace;
|
|
298
|
+
if (this.opts.store) {
|
|
299
|
+
this.opts.store.namespace = namespace;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
278
302
|
generateIterator(iterator) {
|
|
279
303
|
const function_ = async function* () {
|
|
280
304
|
for await (const [key, raw] of typeof iterator === "function" ? iterator(this.opts.store.namespace) : iterator) {
|
package/dist/index.d.cts
CHANGED
|
@@ -8,6 +8,7 @@ declare class EventManager {
|
|
|
8
8
|
on(event: string, listener: EventListener): void;
|
|
9
9
|
removeListener(event: string, listener: EventListener): void;
|
|
10
10
|
off(event: string, listener: EventListener): void;
|
|
11
|
+
once(event: string, listener: EventListener): void;
|
|
11
12
|
emit(event: string, ...arguments_: any[]): void;
|
|
12
13
|
listeners(event: string): EventListener[];
|
|
13
14
|
removeAllListeners(event?: string): void;
|
|
@@ -107,6 +108,16 @@ declare class Keyv<GenericValue = any> extends EventManager {
|
|
|
107
108
|
stats: StatsManager;
|
|
108
109
|
constructor(store?: KeyvStoreAdapter | KeyvOptions | Map<any, any>, options?: Omit<KeyvOptions, 'store'>);
|
|
109
110
|
constructor(options?: KeyvOptions);
|
|
111
|
+
/**
|
|
112
|
+
* Get the current namespace.
|
|
113
|
+
* @returns {string | undefined} The current namespace.
|
|
114
|
+
*/
|
|
115
|
+
get namespace(): string | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Set the current namespace.
|
|
118
|
+
* @param {string | undefined} namespace The namespace to set.
|
|
119
|
+
*/
|
|
120
|
+
set namespace(namespace: string | undefined);
|
|
110
121
|
generateIterator(iterator: IteratorFunction): IteratorFunction;
|
|
111
122
|
_checkIterableAdapter(): boolean;
|
|
112
123
|
_getKeyPrefix(key: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare class EventManager {
|
|
|
8
8
|
on(event: string, listener: EventListener): void;
|
|
9
9
|
removeListener(event: string, listener: EventListener): void;
|
|
10
10
|
off(event: string, listener: EventListener): void;
|
|
11
|
+
once(event: string, listener: EventListener): void;
|
|
11
12
|
emit(event: string, ...arguments_: any[]): void;
|
|
12
13
|
listeners(event: string): EventListener[];
|
|
13
14
|
removeAllListeners(event?: string): void;
|
|
@@ -107,6 +108,16 @@ declare class Keyv<GenericValue = any> extends EventManager {
|
|
|
107
108
|
stats: StatsManager;
|
|
108
109
|
constructor(store?: KeyvStoreAdapter | KeyvOptions | Map<any, any>, options?: Omit<KeyvOptions, 'store'>);
|
|
109
110
|
constructor(options?: KeyvOptions);
|
|
111
|
+
/**
|
|
112
|
+
* Get the current namespace.
|
|
113
|
+
* @returns {string | undefined} The current namespace.
|
|
114
|
+
*/
|
|
115
|
+
get namespace(): string | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Set the current namespace.
|
|
118
|
+
* @param {string | undefined} namespace The namespace to set.
|
|
119
|
+
*/
|
|
120
|
+
set namespace(namespace: string | undefined);
|
|
110
121
|
generateIterator(iterator: IteratorFunction): IteratorFunction;
|
|
111
122
|
_checkIterableAdapter(): boolean;
|
|
112
123
|
_getKeyPrefix(key: string): string;
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,13 @@ var EventManager = class {
|
|
|
42
42
|
this._eventListeners.delete(event);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
once(event, listener) {
|
|
46
|
+
const onceListener = (...arguments_) => {
|
|
47
|
+
listener(...arguments_);
|
|
48
|
+
this.off(event, onceListener);
|
|
49
|
+
};
|
|
50
|
+
this.on(event, onceListener);
|
|
51
|
+
}
|
|
45
52
|
// Emit an event
|
|
46
53
|
emit(event, ...arguments_) {
|
|
47
54
|
const listeners = this._eventListeners.get(event);
|
|
@@ -249,6 +256,23 @@ var Keyv = class extends event_manager_default {
|
|
|
249
256
|
this.stats.enabled = this.opts.stats;
|
|
250
257
|
}
|
|
251
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Get the current namespace.
|
|
261
|
+
* @returns {string | undefined} The current namespace.
|
|
262
|
+
*/
|
|
263
|
+
get namespace() {
|
|
264
|
+
return this.opts.namespace;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Set the current namespace.
|
|
268
|
+
* @param {string | undefined} namespace The namespace to set.
|
|
269
|
+
*/
|
|
270
|
+
set namespace(namespace) {
|
|
271
|
+
this.opts.namespace = namespace;
|
|
272
|
+
if (this.opts.store) {
|
|
273
|
+
this.opts.store.namespace = namespace;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
252
276
|
generateIterator(iterator) {
|
|
253
277
|
const function_ = async function* () {
|
|
254
278
|
for await (const [key, raw] of typeof iterator === "function" ? iterator(this.opts.store.namespace) : iterator) {
|
package/package.json
CHANGED
|
@@ -1,95 +1,99 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
2
|
+
"name": "keyv",
|
|
3
|
+
"version": "5.1.2",
|
|
4
|
+
"description": "Simple key-value storage with support for multiple backends",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"xo": {
|
|
16
|
+
"rules": {
|
|
17
|
+
"import/no-named-as-default": "off",
|
|
18
|
+
"unicorn/prefer-module": "off",
|
|
19
|
+
"unicorn/prefer-node-protocol": "off",
|
|
20
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
21
|
+
"unicorn/no-typeof-undefined": "off",
|
|
22
|
+
"unicorn/prefer-event-target": "off",
|
|
23
|
+
"import/no-extraneous-dependencies": "off",
|
|
24
|
+
"import/extensions": "off",
|
|
25
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
26
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
27
|
+
"@typescript-eslint/no-for-in-array": "off",
|
|
28
|
+
"guard-for-in": "off",
|
|
29
|
+
"no-await-in-loop": "off",
|
|
30
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
31
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
32
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
33
|
+
"@typescript-eslint/naming-convention": "off",
|
|
34
|
+
"@typescript-eslint/consistent-type-assertions": "off",
|
|
35
|
+
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
36
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
37
|
+
"@typescript-eslint/prefer-ts-expect-error": "off"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/jaredwray/keyv.git"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"key",
|
|
46
|
+
"value",
|
|
47
|
+
"store",
|
|
48
|
+
"cache",
|
|
49
|
+
"ttl",
|
|
50
|
+
"key-value",
|
|
51
|
+
"storage",
|
|
52
|
+
"backend",
|
|
53
|
+
"adapter",
|
|
54
|
+
"redis",
|
|
55
|
+
"mongodb",
|
|
56
|
+
"sqlite",
|
|
57
|
+
"mysql",
|
|
58
|
+
"postgresql",
|
|
59
|
+
"memory",
|
|
60
|
+
"node-cache",
|
|
61
|
+
"lru-cache",
|
|
62
|
+
"lru",
|
|
63
|
+
"cache-manager"
|
|
64
|
+
],
|
|
65
|
+
"author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"bugs": {
|
|
68
|
+
"url": "https://github.com/jaredwray/keyv/issues"
|
|
69
|
+
},
|
|
70
|
+
"homepage": "https://github.com/jaredwray/keyv",
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"@keyv/serialize": "*"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@keyv/compress-brotli": "*",
|
|
76
|
+
"@keyv/compress-gzip": "*",
|
|
77
|
+
"@keyv/memcache": "*",
|
|
78
|
+
"@keyv/mongo": "*",
|
|
79
|
+
"@keyv/sqlite": "*",
|
|
80
|
+
"@keyv/test-suite": "*",
|
|
81
|
+
"rimraf": "^6.0.1",
|
|
82
|
+
"timekeeper": "^2.3.1",
|
|
83
|
+
"tsd": "^0.31.2",
|
|
84
|
+
"xo": "^0.59.3"
|
|
85
|
+
},
|
|
86
|
+
"tsd": {
|
|
87
|
+
"directory": "test"
|
|
88
|
+
},
|
|
89
|
+
"files": [
|
|
90
|
+
"dist",
|
|
91
|
+
"LISCENCE"
|
|
92
|
+
],
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
|
|
95
|
+
"test": "xo --fix && vitest run --coverage",
|
|
96
|
+
"test:ci": "xo && vitest --run --sequence.setupFiles=list",
|
|
97
|
+
"clean": "rimraf ./node_modules ./coverage ./test/testdb.sqlite ./dist"
|
|
98
|
+
}
|
|
99
|
+
}
|