@naturalcycles/nodejs-lib 12.90.2 → 12.90.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MemoCache } from '@naturalcycles/js-lib';
|
|
2
|
-
import
|
|
3
|
-
export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE>>;
|
|
2
|
+
import LRUCache from 'lru-cache';
|
|
3
|
+
export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE, any>>;
|
|
4
4
|
/**
|
|
5
5
|
* @example
|
|
6
6
|
* Use it like this:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LRUMemoCache = void 0;
|
|
4
|
-
const
|
|
4
|
+
const lru_cache_1 = require("lru-cache");
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* Use it like this:
|
|
@@ -11,7 +11,7 @@ const LRUCache = require("lru-cache");
|
|
|
11
11
|
*/
|
|
12
12
|
class LRUMemoCache {
|
|
13
13
|
constructor(opt) {
|
|
14
|
-
this.lru = new
|
|
14
|
+
this.lru = new lru_cache_1.default({
|
|
15
15
|
max: 100,
|
|
16
16
|
...opt,
|
|
17
17
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
|
-
"version": "12.90.
|
|
3
|
+
"version": "12.90.3",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"docs-serve": "vuepress dev docs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"got": "^11.0.1",
|
|
34
34
|
"joi": "17.4.2",
|
|
35
35
|
"jsonwebtoken": "^9.0.0",
|
|
36
|
-
"lru-cache": "^
|
|
36
|
+
"lru-cache": "^8.0.4",
|
|
37
37
|
"move-file": "^2.0.0",
|
|
38
38
|
"through2-concurrent": "^2.0.0",
|
|
39
39
|
"yargs": "^17.0.0"
|
package/src/util/lruMemoCache.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MemoCache } from '@naturalcycles/js-lib'
|
|
2
|
-
import
|
|
2
|
+
import LRUCache from 'lru-cache'
|
|
3
3
|
|
|
4
4
|
// Partial, to be able to provide default `max`
|
|
5
|
-
export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE>>
|
|
5
|
+
export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE, any>>
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @example
|
|
@@ -13,13 +13,13 @@ export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALU
|
|
|
13
13
|
*/
|
|
14
14
|
export class LRUMemoCache<KEY = any, VALUE = any> implements MemoCache<KEY, VALUE> {
|
|
15
15
|
constructor(opt: LRUMemoCacheOptions<KEY, VALUE>) {
|
|
16
|
-
this.lru = new LRUCache<
|
|
16
|
+
this.lru = new LRUCache<any, any>({
|
|
17
17
|
max: 100,
|
|
18
18
|
...opt,
|
|
19
19
|
})
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
private lru!: LRUCache<
|
|
22
|
+
private lru!: LRUCache<any, any>
|
|
23
23
|
|
|
24
24
|
has(k: any): boolean {
|
|
25
25
|
return this.lru.has(k)
|