@keyvhq/memoize 2.0.0 → 2.1.0
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/package.json +5 -5
- package/src/index.d.ts +18 -0
package/package.json
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"name": "@keyvhq/memoize",
|
|
3
3
|
"description": "Memoize any function using Keyv as storage backend.",
|
|
4
4
|
"homepage": "https://keyv.js.org",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.1.0",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
6
7
|
"main": "src/index.js",
|
|
7
8
|
"author": {
|
|
8
9
|
"email": "hello@microlink.io",
|
|
@@ -28,12 +29,11 @@
|
|
|
28
29
|
"value"
|
|
29
30
|
],
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@keyvhq/core": "^2.
|
|
32
|
+
"@keyvhq/core": "^2.1.0",
|
|
32
33
|
"mimic-fn": "~3.0.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"ava": "latest"
|
|
36
|
-
"delay": "latest"
|
|
36
|
+
"ava": "latest"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">= 16"
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "3ca2c5cc0dc9914ec448c91be57db4a17f2cafe2"
|
|
52
52
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Options, Store } from '@keyvhq/core'
|
|
2
|
+
|
|
3
|
+
declare function memoize<RawResult, Result, Args extends any[]> (
|
|
4
|
+
fn: (...args: Args) => Promise<RawResult>,
|
|
5
|
+
keyvOptions: Options | Store,
|
|
6
|
+
options: {
|
|
7
|
+
key?: (value: RawResult) => any
|
|
8
|
+
objectMode?: boolean
|
|
9
|
+
staleTtl?: number | boolean | ((value: any) => number | boolean)
|
|
10
|
+
ttl?: number | ((value: any) => number)
|
|
11
|
+
// Difficult to type this one, so we'll just leave it as any
|
|
12
|
+
// When options.value is not provided, the return type of the memoized function is Result
|
|
13
|
+
// I can't figure out how to type this, so I'm just going to leave it as any
|
|
14
|
+
value?: (value: RawResult) => Result
|
|
15
|
+
}
|
|
16
|
+
): (...args: Args) => Promise<RawResult>
|
|
17
|
+
|
|
18
|
+
export default memoize
|