cacheable 1.8.2 → 1.8.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/dist/index.cjs +4 -4
- package/dist/index.d.cts +6 -10
- package/dist/index.d.ts +6 -10
- package/dist/index.js +4 -4
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -713,8 +713,8 @@ var CacheableMemory = class {
|
|
|
713
713
|
*/
|
|
714
714
|
wrap(function_, options) {
|
|
715
715
|
const wrapOptions = {
|
|
716
|
-
ttl: options.
|
|
717
|
-
keyPrefix: options
|
|
716
|
+
ttl: options?.ttl ?? this._ttl,
|
|
717
|
+
keyPrefix: options?.keyPrefix,
|
|
718
718
|
cache: this
|
|
719
719
|
};
|
|
720
720
|
return wrapSync(function_, wrapOptions);
|
|
@@ -1522,8 +1522,8 @@ var Cacheable = class extends import_hookified.Hookified {
|
|
|
1522
1522
|
*/
|
|
1523
1523
|
wrap(function_, options) {
|
|
1524
1524
|
const wrapOptions = {
|
|
1525
|
-
ttl: options.
|
|
1526
|
-
keyPrefix: options
|
|
1525
|
+
ttl: options?.ttl ?? this._ttl,
|
|
1526
|
+
keyPrefix: options?.keyPrefix,
|
|
1527
1527
|
cache: this
|
|
1528
1528
|
};
|
|
1529
1529
|
return wrap(function_, wrapOptions);
|
package/dist/index.d.cts
CHANGED
|
@@ -109,20 +109,16 @@ type CacheableStoreItem = {
|
|
|
109
109
|
expires?: number;
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
type
|
|
112
|
+
type WrapFunctionOptions = {
|
|
113
113
|
ttl?: number | string;
|
|
114
114
|
keyPrefix?: string;
|
|
115
|
+
};
|
|
116
|
+
type WrapOptions = WrapFunctionOptions & {
|
|
115
117
|
cache: Cacheable;
|
|
116
118
|
};
|
|
117
|
-
type WrapSyncOptions = {
|
|
118
|
-
ttl?: number | string;
|
|
119
|
-
keyPrefix?: string;
|
|
119
|
+
type WrapSyncOptions = WrapFunctionOptions & {
|
|
120
120
|
cache: CacheableMemory;
|
|
121
121
|
};
|
|
122
|
-
type WrapFunctionOptions = {
|
|
123
|
-
ttl?: number | string;
|
|
124
|
-
keyPrefix: string;
|
|
125
|
-
};
|
|
126
122
|
type AnyFunction = (...arguments_: any[]) => any;
|
|
127
123
|
declare function wrapSync<T>(function_: AnyFunction, options: WrapSyncOptions): AnyFunction;
|
|
128
124
|
declare function wrap<T>(function_: AnyFunction, options: WrapOptions): AnyFunction;
|
|
@@ -369,7 +365,7 @@ declare class CacheableMemory {
|
|
|
369
365
|
* @param {Object} [options] - The options to wrap
|
|
370
366
|
* @returns {Function} - The wrapped function
|
|
371
367
|
*/
|
|
372
|
-
wrap<T>(function_: (...arguments_: any[]) => T, options
|
|
368
|
+
wrap<T>(function_: (...arguments_: any[]) => T, options?: WrapFunctionOptions): (...arguments_: any[]) => T;
|
|
373
369
|
private isPrimitive;
|
|
374
370
|
private concatStores;
|
|
375
371
|
private setTtl;
|
|
@@ -625,7 +621,7 @@ declare class Cacheable extends Hookified {
|
|
|
625
621
|
* @param {WrapOptions} [options] The options for the wrap function
|
|
626
622
|
* @returns {Function} The wrapped function
|
|
627
623
|
*/
|
|
628
|
-
wrap<T>(function_: (...arguments_: any[]) => T, options
|
|
624
|
+
wrap<T>(function_: (...arguments_: any[]) => T, options?: WrapFunctionOptions): (...arguments_: any[]) => T;
|
|
629
625
|
/**
|
|
630
626
|
* Will hash an object using the specified algorithm. The default algorithm is 'sha256'.
|
|
631
627
|
* @param {any} object the object to hash
|
package/dist/index.d.ts
CHANGED
|
@@ -109,20 +109,16 @@ type CacheableStoreItem = {
|
|
|
109
109
|
expires?: number;
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
type
|
|
112
|
+
type WrapFunctionOptions = {
|
|
113
113
|
ttl?: number | string;
|
|
114
114
|
keyPrefix?: string;
|
|
115
|
+
};
|
|
116
|
+
type WrapOptions = WrapFunctionOptions & {
|
|
115
117
|
cache: Cacheable;
|
|
116
118
|
};
|
|
117
|
-
type WrapSyncOptions = {
|
|
118
|
-
ttl?: number | string;
|
|
119
|
-
keyPrefix?: string;
|
|
119
|
+
type WrapSyncOptions = WrapFunctionOptions & {
|
|
120
120
|
cache: CacheableMemory;
|
|
121
121
|
};
|
|
122
|
-
type WrapFunctionOptions = {
|
|
123
|
-
ttl?: number | string;
|
|
124
|
-
keyPrefix: string;
|
|
125
|
-
};
|
|
126
122
|
type AnyFunction = (...arguments_: any[]) => any;
|
|
127
123
|
declare function wrapSync<T>(function_: AnyFunction, options: WrapSyncOptions): AnyFunction;
|
|
128
124
|
declare function wrap<T>(function_: AnyFunction, options: WrapOptions): AnyFunction;
|
|
@@ -369,7 +365,7 @@ declare class CacheableMemory {
|
|
|
369
365
|
* @param {Object} [options] - The options to wrap
|
|
370
366
|
* @returns {Function} - The wrapped function
|
|
371
367
|
*/
|
|
372
|
-
wrap<T>(function_: (...arguments_: any[]) => T, options
|
|
368
|
+
wrap<T>(function_: (...arguments_: any[]) => T, options?: WrapFunctionOptions): (...arguments_: any[]) => T;
|
|
373
369
|
private isPrimitive;
|
|
374
370
|
private concatStores;
|
|
375
371
|
private setTtl;
|
|
@@ -625,7 +621,7 @@ declare class Cacheable extends Hookified {
|
|
|
625
621
|
* @param {WrapOptions} [options] The options for the wrap function
|
|
626
622
|
* @returns {Function} The wrapped function
|
|
627
623
|
*/
|
|
628
|
-
wrap<T>(function_: (...arguments_: any[]) => T, options
|
|
624
|
+
wrap<T>(function_: (...arguments_: any[]) => T, options?: WrapFunctionOptions): (...arguments_: any[]) => T;
|
|
629
625
|
/**
|
|
630
626
|
* Will hash an object using the specified algorithm. The default algorithm is 'sha256'.
|
|
631
627
|
* @param {any} object the object to hash
|
package/dist/index.js
CHANGED
|
@@ -668,8 +668,8 @@ var CacheableMemory = class {
|
|
|
668
668
|
*/
|
|
669
669
|
wrap(function_, options) {
|
|
670
670
|
const wrapOptions = {
|
|
671
|
-
ttl: options.
|
|
672
|
-
keyPrefix: options
|
|
671
|
+
ttl: options?.ttl ?? this._ttl,
|
|
672
|
+
keyPrefix: options?.keyPrefix,
|
|
673
673
|
cache: this
|
|
674
674
|
};
|
|
675
675
|
return wrapSync(function_, wrapOptions);
|
|
@@ -1480,8 +1480,8 @@ var Cacheable = class extends Hookified {
|
|
|
1480
1480
|
*/
|
|
1481
1481
|
wrap(function_, options) {
|
|
1482
1482
|
const wrapOptions = {
|
|
1483
|
-
ttl: options.
|
|
1484
|
-
keyPrefix: options
|
|
1483
|
+
ttl: options?.ttl ?? this._ttl,
|
|
1484
|
+
keyPrefix: options?.keyPrefix,
|
|
1485
1485
|
cache: this
|
|
1486
1486
|
};
|
|
1487
1487
|
return wrap(function_, wrapOptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cacheable",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "Simple Caching Engine using Keyv",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"private": false,
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@keyv/redis": "^3.0.1",
|
|
25
|
-
"@types/node": "^22.8.
|
|
26
|
-
"@vitest/coverage-v8": "^2.1.
|
|
25
|
+
"@types/node": "^22.8.4",
|
|
26
|
+
"@vitest/coverage-v8": "^2.1.4",
|
|
27
27
|
"lru-cache": "^11.0.1",
|
|
28
28
|
"rimraf": "^6.0.1",
|
|
29
29
|
"tsup": "^8.3.5",
|
|
30
30
|
"typescript": "^5.6.3",
|
|
31
|
-
"vitest": "^2.1.
|
|
31
|
+
"vitest": "^2.1.4",
|
|
32
32
|
"xo": "^0.59.3"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"hookified": "^1.
|
|
35
|
+
"hookified": "^1.5.0",
|
|
36
36
|
"keyv": "^5.1.2"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|