@extra-memoize/extra-disk-cache 0.6.5 → 0.8.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/README.md +4 -14
- package/lib/disk-cache.d.ts +8 -0
- package/lib/disk-cache.js +24 -0
- package/lib/disk-cache.js.map +1 -0
- package/lib/{es2015/index.d.ts → index.d.ts} +0 -0
- package/lib/{es2015/index.js → index.js} +0 -0
- package/lib/index.js.map +1 -0
- package/lib/{es2018/stale-if-error-async-disk-cache.d.ts → stale-if-error-async-disk-cache.d.ts} +3 -4
- package/lib/{es2018/stale-if-error-async-disk-cache.js → stale-if-error-async-disk-cache.js} +4 -12
- package/lib/stale-if-error-async-disk-cache.js.map +1 -0
- package/lib/{es2018/stale-while-revalidate-and-stale-if-error-async-disk-cache.d.ts → stale-while-revalidate-and-stale-if-error-async-disk-cache.d.ts} +3 -4
- package/lib/{es2018/stale-while-revalidate-and-stale-if-error-async-disk-cache.js → stale-while-revalidate-and-stale-if-error-async-disk-cache.js} +4 -12
- package/lib/stale-while-revalidate-and-stale-if-error-async-disk-cache.js.map +1 -0
- package/lib/{es2015/stale-while-revalidate-async-disk-cache.d.ts → stale-while-revalidate-async-disk-cache.d.ts} +3 -4
- package/lib/{es2015/stale-while-revalidate-async-disk-cache.js → stale-while-revalidate-async-disk-cache.js} +4 -12
- package/lib/stale-while-revalidate-async-disk-cache.js.map +1 -0
- package/package.json +13 -17
- package/lib/es2015/disk-cache.d.ts +0 -9
- package/lib/es2015/disk-cache.js +0 -32
- package/lib/es2015/disk-cache.js.map +0 -1
- package/lib/es2015/index.js.map +0 -1
- package/lib/es2015/stale-if-error-async-disk-cache.d.ts +0 -11
- package/lib/es2015/stale-if-error-async-disk-cache.js +0 -43
- package/lib/es2015/stale-if-error-async-disk-cache.js.map +0 -1
- package/lib/es2015/stale-while-revalidate-and-stale-if-error-async-disk-cache.d.ts +0 -12
- package/lib/es2015/stale-while-revalidate-and-stale-if-error-async-disk-cache.js +0 -47
- package/lib/es2015/stale-while-revalidate-and-stale-if-error-async-disk-cache.js.map +0 -1
- package/lib/es2015/stale-while-revalidate-async-disk-cache.js.map +0 -1
- package/lib/es2015/utils.d.ts +0 -3
- package/lib/es2015/utils.js +0 -12
- package/lib/es2015/utils.js.map +0 -1
- package/lib/es2018/disk-cache.d.ts +0 -9
- package/lib/es2018/disk-cache.js +0 -32
- package/lib/es2018/disk-cache.js.map +0 -1
- package/lib/es2018/index.d.ts +0 -4
- package/lib/es2018/index.js +0 -21
- package/lib/es2018/index.js.map +0 -1
- package/lib/es2018/stale-if-error-async-disk-cache.js.map +0 -1
- package/lib/es2018/stale-while-revalidate-and-stale-if-error-async-disk-cache.js.map +0 -1
- package/lib/es2018/stale-while-revalidate-async-disk-cache.d.ts +0 -12
- package/lib/es2018/stale-while-revalidate-async-disk-cache.js +0 -44
- package/lib/es2018/stale-while-revalidate-async-disk-cache.js.map +0 -1
- package/lib/es2018/utils.d.ts +0 -3
- package/lib/es2018/utils.js +0 -12
- package/lib/es2018/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -14,11 +14,7 @@ yarn add @extra-memoize/extra-disk-cache
|
|
|
14
14
|
#### DiskCache
|
|
15
15
|
```ts
|
|
16
16
|
class DiskCache<T> implements ICache<T> {
|
|
17
|
-
constructor(
|
|
18
|
-
cache: ExtraDiskCache
|
|
19
|
-
, toBuffer?: (value: T) => Buffer
|
|
20
|
-
, fromBuffer?: (buffer: Buffer) => T
|
|
21
|
-
)
|
|
17
|
+
constructor(view: DiskCacheView<string, T>)
|
|
22
18
|
}
|
|
23
19
|
```
|
|
24
20
|
|
|
@@ -26,11 +22,9 @@ class DiskCache<T> implements ICache<T> {
|
|
|
26
22
|
```ts
|
|
27
23
|
class StaleWhileRevalidateDiskCache<T> implements IStaleWhileRevalidateCache<T> {
|
|
28
24
|
constructor(
|
|
29
|
-
|
|
25
|
+
view: DiskCacheView<string, T>
|
|
30
26
|
, timeToLive: number
|
|
31
27
|
, staleWhileRevalidate: number
|
|
32
|
-
, toBuffer?: (value: T) => Buffer
|
|
33
|
-
, fromBuffer?: (buffer: Buffer) => T
|
|
34
28
|
)
|
|
35
29
|
}
|
|
36
30
|
```
|
|
@@ -39,11 +33,9 @@ class StaleWhileRevalidateDiskCache<T> implements IStaleWhileRevalidateCache<T>
|
|
|
39
33
|
```ts
|
|
40
34
|
class StaleIfErrorDiskCache<T> implements IStaleIfErrorCache<T> {
|
|
41
35
|
constructor(
|
|
42
|
-
|
|
36
|
+
view: DiskCacheView<string, T>
|
|
43
37
|
, timeToLive: number
|
|
44
38
|
, staleIfError: number
|
|
45
|
-
, toBuffer?: (value: T) => Buffer
|
|
46
|
-
, fromBuffer?: (buffer: Buffer) => T
|
|
47
39
|
)
|
|
48
40
|
}
|
|
49
41
|
```
|
|
@@ -52,12 +44,10 @@ class StaleIfErrorDiskCache<T> implements IStaleIfErrorCache<T> {
|
|
|
52
44
|
```ts
|
|
53
45
|
class StaleWhileRevalidateAndStaleIfErrorDiskCache<T> implements IStaleWhileRevalidateAndStaleIfErrorCache<T> {
|
|
54
46
|
constructor(
|
|
55
|
-
|
|
47
|
+
view: DiskCacheView<string, T>
|
|
56
48
|
, timeToLive: number
|
|
57
49
|
, staleWhileRevalidate: number
|
|
58
50
|
, staleIfError: number
|
|
59
|
-
, toBuffer?: (value: T) => Buffer
|
|
60
|
-
, fromBuffer?: (buffer: Buffer) => T
|
|
61
51
|
)
|
|
62
52
|
}
|
|
63
53
|
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ICache, State } from 'extra-memoize';
|
|
2
|
+
import { DiskCacheView } from 'extra-disk-cache';
|
|
3
|
+
export declare class DiskCache<T> implements ICache<T> {
|
|
4
|
+
private view;
|
|
5
|
+
constructor(view: DiskCacheView<string, T>);
|
|
6
|
+
get(key: string): [State.Miss] | [State.Hit, T];
|
|
7
|
+
set(key: string, value: T): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiskCache = void 0;
|
|
4
|
+
const extra_memoize_1 = require("extra-memoize");
|
|
5
|
+
const prelude_1 = require("@blackglory/prelude");
|
|
6
|
+
class DiskCache {
|
|
7
|
+
constructor(view) {
|
|
8
|
+
this.view = view;
|
|
9
|
+
}
|
|
10
|
+
get(key) {
|
|
11
|
+
const item = this.view.getWithMetadata(key);
|
|
12
|
+
if ((0, prelude_1.isUndefined)(item)) {
|
|
13
|
+
return [extra_memoize_1.State.Miss];
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return [extra_memoize_1.State.Hit, item.value];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
set(key, value) {
|
|
20
|
+
this.view.set(key, value, Date.now());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.DiskCache = DiskCache;
|
|
24
|
+
//# sourceMappingURL=disk-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disk-cache.js","sourceRoot":"","sources":["../src/disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAE7C,iDAAiD;AAEjD,MAAa,SAAS;IACpB,YAAoB,IAA8B;QAA9B,SAAI,GAAJ,IAAI,CAA0B;IAAG,CAAC;IAEtD,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;QAC3C,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;SAC/B;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IACvC,CAAC;CACF;AAjBD,8BAiBC"}
|
|
File without changes
|
|
File without changes
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,4EAAyD;AACzD,oEAAiD;AACjD,+FAA4E"}
|
package/lib/{es2018/stale-if-error-async-disk-cache.d.ts → stale-if-error-async-disk-cache.d.ts}
RENAMED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { IStaleIfErrorCache, State } from 'extra-memoize';
|
|
3
|
-
import {
|
|
2
|
+
import { DiskCacheView } from 'extra-disk-cache';
|
|
4
3
|
export declare class StaleIfErrorDiskCache<T> implements IStaleIfErrorCache<T> {
|
|
4
|
+
private view;
|
|
5
5
|
private timeToLive;
|
|
6
6
|
private staleIfError;
|
|
7
|
-
|
|
8
|
-
constructor(cache: DiskCache, timeToLive: number, staleIfError: number, toBuffer?: (value: T) => Buffer, fromBuffer?: (buffer: Buffer) => T);
|
|
7
|
+
constructor(view: DiskCacheView<string, T>, timeToLive: number, staleIfError: number);
|
|
9
8
|
get(key: string): [State.Miss] | [State.Hit | State.StaleIfError, T];
|
|
10
9
|
set(key: string, value: T): void;
|
|
11
10
|
}
|
package/lib/{es2018/stale-if-error-async-disk-cache.js → stale-if-error-async-disk-cache.js}
RENAMED
|
@@ -2,23 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StaleIfErrorDiskCache = void 0;
|
|
4
4
|
const extra_memoize_1 = require("extra-memoize");
|
|
5
|
-
const extra_disk_cache_1 = require("extra-disk-cache");
|
|
6
5
|
const prelude_1 = require("@blackglory/prelude");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
6
|
class StaleIfErrorDiskCache {
|
|
9
|
-
constructor(
|
|
7
|
+
constructor(view, timeToLive, staleIfError) {
|
|
8
|
+
this.view = view;
|
|
10
9
|
this.timeToLive = timeToLive;
|
|
11
10
|
this.staleIfError = staleIfError;
|
|
12
|
-
this.cache = new extra_disk_cache_1.DiskCacheView(cache, {
|
|
13
|
-
toString: x => x,
|
|
14
|
-
fromString: x => x
|
|
15
|
-
}, {
|
|
16
|
-
toBuffer,
|
|
17
|
-
fromBuffer
|
|
18
|
-
});
|
|
19
11
|
}
|
|
20
12
|
get(key) {
|
|
21
|
-
const item = this.
|
|
13
|
+
const item = this.view.getWithMetadata(key);
|
|
22
14
|
if ((0, prelude_1.isUndefined)(item)) {
|
|
23
15
|
return [extra_memoize_1.State.Miss];
|
|
24
16
|
}
|
|
@@ -36,7 +28,7 @@ class StaleIfErrorDiskCache {
|
|
|
36
28
|
}
|
|
37
29
|
}
|
|
38
30
|
set(key, value) {
|
|
39
|
-
this.
|
|
31
|
+
this.view.set(key, value, this.timeToLive + this.staleIfError);
|
|
40
32
|
}
|
|
41
33
|
}
|
|
42
34
|
exports.StaleIfErrorDiskCache = StaleIfErrorDiskCache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stale-if-error-async-disk-cache.js","sourceRoot":"","sources":["../src/stale-if-error-async-disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAAyD;AAEzD,iDAAiD;AAEjD,MAAa,qBAAqB;IAChC,YACU,IAA8B,EAC9B,UAAkB,EAClB,YAAoB;QAFpB,SAAI,GAAJ,IAAI,CAA0B;QAC9B,eAAU,GAAV,UAAU,CAAQ;QAClB,iBAAY,GAAZ,YAAY,CAAQ;IAC3B,CAAC;IAEJ,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;QAC3C,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;YAC3C,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE;gBAC9B,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAC/B;iBAAM,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE;gBACzD,OAAO,CAAC,qBAAK,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aACxC;iBAAM;gBAEL,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;aACpB;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CACX,GAAG,EACH,KAAK,EACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CACpC,CAAA;IACH,CAAC;CACF;AAjCD,sDAiCC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { IStaleWhileRevalidateAndStaleIfErrorCache, State } from 'extra-memoize';
|
|
3
|
-
import {
|
|
2
|
+
import { DiskCacheView } from 'extra-disk-cache';
|
|
4
3
|
export declare class StaleWhileRevalidateAndStaleIfErrorDiskCache<T> implements IStaleWhileRevalidateAndStaleIfErrorCache<T> {
|
|
4
|
+
private view;
|
|
5
5
|
private timeToLive;
|
|
6
6
|
private staleWhileRevalidate;
|
|
7
7
|
private staleIfError;
|
|
8
|
-
|
|
9
|
-
constructor(cache: DiskCache, timeToLive: number, staleWhileRevalidate: number, staleIfError: number, toBuffer?: (value: T) => Buffer, fromBuffer?: (buffer: Buffer) => T);
|
|
8
|
+
constructor(view: DiskCacheView<string, T>, timeToLive: number, staleWhileRevalidate: number, staleIfError: number);
|
|
10
9
|
get(key: string): [State.Miss] | [State.Hit | State.StaleWhileRevalidate | State.StaleIfError, T];
|
|
11
10
|
set(key: string, value: T): void;
|
|
12
11
|
}
|
|
@@ -2,24 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StaleWhileRevalidateAndStaleIfErrorDiskCache = void 0;
|
|
4
4
|
const extra_memoize_1 = require("extra-memoize");
|
|
5
|
-
const extra_disk_cache_1 = require("extra-disk-cache");
|
|
6
5
|
const prelude_1 = require("@blackglory/prelude");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
6
|
class StaleWhileRevalidateAndStaleIfErrorDiskCache {
|
|
9
|
-
constructor(
|
|
7
|
+
constructor(view, timeToLive, staleWhileRevalidate, staleIfError) {
|
|
8
|
+
this.view = view;
|
|
10
9
|
this.timeToLive = timeToLive;
|
|
11
10
|
this.staleWhileRevalidate = staleWhileRevalidate;
|
|
12
11
|
this.staleIfError = staleIfError;
|
|
13
|
-
this.cache = new extra_disk_cache_1.DiskCacheView(cache, {
|
|
14
|
-
toString: x => x,
|
|
15
|
-
fromString: x => x
|
|
16
|
-
}, {
|
|
17
|
-
toBuffer,
|
|
18
|
-
fromBuffer
|
|
19
|
-
});
|
|
20
12
|
}
|
|
21
13
|
get(key) {
|
|
22
|
-
const item = this.
|
|
14
|
+
const item = this.view.getWithMetadata(key);
|
|
23
15
|
if ((0, prelude_1.isUndefined)(item)) {
|
|
24
16
|
return [extra_memoize_1.State.Miss];
|
|
25
17
|
}
|
|
@@ -40,7 +32,7 @@ class StaleWhileRevalidateAndStaleIfErrorDiskCache {
|
|
|
40
32
|
}
|
|
41
33
|
}
|
|
42
34
|
set(key, value) {
|
|
43
|
-
this.
|
|
35
|
+
this.view.set(key, value, this.timeToLive + this.staleWhileRevalidate + this.staleIfError);
|
|
44
36
|
}
|
|
45
37
|
}
|
|
46
38
|
exports.StaleWhileRevalidateAndStaleIfErrorDiskCache = StaleWhileRevalidateAndStaleIfErrorDiskCache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stale-while-revalidate-and-stale-if-error-async-disk-cache.js","sourceRoot":"","sources":["../src/stale-while-revalidate-and-stale-if-error-async-disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAAgF;AAEhF,iDAAiD;AAEjD,MAAa,4CAA4C;IACvD,YACU,IAA8B,EAC9B,UAAkB,EAClB,oBAA4B,EAC5B,YAAoB;QAHpB,SAAI,GAAJ,IAAI,CAA0B;QAC9B,eAAU,GAAV,UAAU,CAAQ;QAClB,yBAAoB,GAApB,oBAAoB,CAAQ;QAC5B,iBAAY,GAAZ,YAAY,CAAQ;IAC3B,CAAC;IAEJ,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;QAC3C,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;YAC3C,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE;gBAC9B,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAC/B;iBAAM,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,EAAE;gBACjE,OAAO,CAAC,qBAAK,CAAC,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAChD;iBAAM,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,YAAY,EAAE;gBACrF,OAAO,CAAC,qBAAK,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aACxC;iBAAM;gBAEL,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;aACpB;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CACX,GAAG,EACH,KAAK,EACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,YAAY,CAChE,CAAA;IACH,CAAC;CACF;AApCD,oGAoCC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { IStaleWhileRevalidateCache, State } from 'extra-memoize';
|
|
3
|
-
import {
|
|
2
|
+
import { DiskCacheView } from 'extra-disk-cache';
|
|
4
3
|
export declare class StaleWhileRevalidateDiskCache<T> implements IStaleWhileRevalidateCache<T> {
|
|
4
|
+
private view;
|
|
5
5
|
private timeToLive;
|
|
6
6
|
private staleWhileRevalidate;
|
|
7
|
-
|
|
8
|
-
constructor(cache: DiskCache, timeToLive: number, staleWhileRevalidate: number, toBuffer?: (value: T) => Buffer, fromBuffer?: (buffer: Buffer) => T);
|
|
7
|
+
constructor(view: DiskCacheView<string, T>, timeToLive: number, staleWhileRevalidate: number);
|
|
9
8
|
get(key: string): [State.Miss] | [State.Hit | State.StaleWhileRevalidate, T];
|
|
10
9
|
set(key: string, value: T): void;
|
|
11
10
|
private isStaleWhileRevalidate;
|
|
@@ -2,23 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StaleWhileRevalidateDiskCache = void 0;
|
|
4
4
|
const extra_memoize_1 = require("extra-memoize");
|
|
5
|
-
const extra_disk_cache_1 = require("extra-disk-cache");
|
|
6
5
|
const prelude_1 = require("@blackglory/prelude");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
6
|
class StaleWhileRevalidateDiskCache {
|
|
9
|
-
constructor(
|
|
7
|
+
constructor(view, timeToLive, staleWhileRevalidate) {
|
|
8
|
+
this.view = view;
|
|
10
9
|
this.timeToLive = timeToLive;
|
|
11
10
|
this.staleWhileRevalidate = staleWhileRevalidate;
|
|
12
|
-
this.cache = new extra_disk_cache_1.DiskCacheView(cache, {
|
|
13
|
-
toString: x => x,
|
|
14
|
-
fromString: x => x
|
|
15
|
-
}, {
|
|
16
|
-
toBuffer,
|
|
17
|
-
fromBuffer
|
|
18
|
-
});
|
|
19
11
|
}
|
|
20
12
|
get(key) {
|
|
21
|
-
const item = this.
|
|
13
|
+
const item = this.view.getWithMetadata(key);
|
|
22
14
|
if ((0, prelude_1.isUndefined)(item)) {
|
|
23
15
|
return [extra_memoize_1.State.Miss];
|
|
24
16
|
}
|
|
@@ -32,7 +24,7 @@ class StaleWhileRevalidateDiskCache {
|
|
|
32
24
|
}
|
|
33
25
|
}
|
|
34
26
|
set(key, value) {
|
|
35
|
-
this.
|
|
27
|
+
this.view.set(key, value, this.timeToLive + this.staleWhileRevalidate);
|
|
36
28
|
}
|
|
37
29
|
isStaleWhileRevalidate(updatedAt) {
|
|
38
30
|
const elapsed = Date.now() - updatedAt;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stale-while-revalidate-async-disk-cache.js","sourceRoot":"","sources":["../src/stale-while-revalidate-async-disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAAiE;AAEjE,iDAAiD;AAEjD,MAAa,6BAA6B;IACxC,YACU,IAA8B,EAC9B,UAAkB,EAClB,oBAA4B;QAF5B,SAAI,GAAJ,IAAI,CAA0B;QAC9B,eAAU,GAAV,UAAU,CAAQ;QAClB,yBAAoB,GAApB,oBAAoB,CAAQ;IACnC,CAAC;IAEJ,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;QAC3C,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,IAAI,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAC/C,OAAO,CAAC,qBAAK,CAAC,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAChD;iBAAM;gBACL,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAC/B;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CACX,GAAG,EACH,KAAK,EACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAC5C,CAAA;IACH,CAAC;IAEO,sBAAsB,CAAC,SAAiB;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAA;QACtC,OAAO,OAAO,GAAG,IAAI,CAAC,UAAU;eACzB,OAAO,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAA;IAC9D,CAAC;CACF;AAnCD,sEAmCC"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@extra-memoize/extra-disk-cache",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
7
7
|
],
|
|
8
|
-
"main": "lib/
|
|
9
|
-
"types": "lib/
|
|
8
|
+
"main": "lib/index.js",
|
|
9
|
+
"types": "lib/index.d.ts",
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"repository": "git@github.com:extra-memoize/extra-disk-cache.git",
|
|
12
12
|
"author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
|
|
@@ -19,13 +19,9 @@
|
|
|
19
19
|
"prepublishOnly": "run-s clean build",
|
|
20
20
|
"clean": "run-p clean:*",
|
|
21
21
|
"clean:build": "rimraf lib",
|
|
22
|
-
"build": "run-
|
|
23
|
-
"build:
|
|
24
|
-
"build:
|
|
25
|
-
"build:es2015:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib/es2015",
|
|
26
|
-
"build:es2018": "run-s build:es2018:*",
|
|
27
|
-
"build:es2018:compile": "tsc --project tsconfig.build.json --module commonjs --target es2018 --outDir lib/es2018",
|
|
28
|
-
"build:es2018:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib/es2018",
|
|
22
|
+
"build": "run-s build:*",
|
|
23
|
+
"build:compile": "tsc --project tsconfig.build.json --module commonjs --target es2018 --outDir lib",
|
|
24
|
+
"build:patch": "tscpaths -p tsconfig.build.json -s ./src -o ./lib",
|
|
29
25
|
"release": "standard-version"
|
|
30
26
|
},
|
|
31
27
|
"husky": {
|
|
@@ -38,11 +34,11 @@
|
|
|
38
34
|
"@blackglory/jest-matchers": "^0.5.0",
|
|
39
35
|
"@commitlint/cli": "^17.3.0",
|
|
40
36
|
"@commitlint/config-conventional": "^17.3.0",
|
|
41
|
-
"@types/jest": "^29.2.
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
43
|
-
"@typescript-eslint/parser": "^5.
|
|
44
|
-
"eslint": "^8.
|
|
45
|
-
"extra-disk-cache": "^0.
|
|
37
|
+
"@types/jest": "^29.2.4",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^5.46.0",
|
|
39
|
+
"@typescript-eslint/parser": "^5.46.0",
|
|
40
|
+
"eslint": "^8.29.0",
|
|
41
|
+
"extra-disk-cache": "^0.10.1",
|
|
46
42
|
"extra-memoize": "^0.9.1",
|
|
47
43
|
"husky": "^4.3.8",
|
|
48
44
|
"jest": "^29.3.1",
|
|
@@ -53,13 +49,13 @@
|
|
|
53
49
|
"ts-jest": "^29.0.3",
|
|
54
50
|
"tscpaths": "^0.0.9",
|
|
55
51
|
"tslib": "^2.4.1",
|
|
56
|
-
"typescript": "^4.9.
|
|
52
|
+
"typescript": "^4.9.4"
|
|
57
53
|
},
|
|
58
54
|
"dependencies": {
|
|
59
55
|
"@blackglory/prelude": "^0.1.8"
|
|
60
56
|
},
|
|
61
57
|
"peerDependencies": {
|
|
62
|
-
"extra-disk-cache": "^0.
|
|
58
|
+
"extra-disk-cache": "^0.10.1",
|
|
63
59
|
"extra-memoize": "^0.6.0 || ^0.7.0 || ^0.8.0 || ^0.9.0"
|
|
64
60
|
}
|
|
65
61
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ICache, State } from 'extra-memoize';
|
|
3
|
-
import { DiskCache as ExtraDiskCache } from 'extra-disk-cache';
|
|
4
|
-
export declare class DiskCache<T> implements ICache<T> {
|
|
5
|
-
private cache;
|
|
6
|
-
constructor(cache: ExtraDiskCache, toBuffer?: (value: T) => Buffer, fromBuffer?: (buffer: Buffer) => T);
|
|
7
|
-
get(key: string): [State.Miss] | [State.Hit, T];
|
|
8
|
-
set(key: string, value: T): void;
|
|
9
|
-
}
|
package/lib/es2015/disk-cache.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DiskCache = void 0;
|
|
4
|
-
const extra_memoize_1 = require("extra-memoize");
|
|
5
|
-
const extra_disk_cache_1 = require("extra-disk-cache");
|
|
6
|
-
const prelude_1 = require("@blackglory/prelude");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
class DiskCache {
|
|
9
|
-
constructor(cache, toBuffer = utils_1.defaultToBuffer, fromBuffer = utils_1.defaultFromBuffer) {
|
|
10
|
-
this.cache = new extra_disk_cache_1.DiskCacheView(cache, {
|
|
11
|
-
toString: x => x,
|
|
12
|
-
fromString: x => x
|
|
13
|
-
}, {
|
|
14
|
-
toBuffer,
|
|
15
|
-
fromBuffer
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
get(key) {
|
|
19
|
-
const item = this.cache.get(key);
|
|
20
|
-
if ((0, prelude_1.isUndefined)(item)) {
|
|
21
|
-
return [extra_memoize_1.State.Miss];
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return [extra_memoize_1.State.Hit, item.value];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
set(key, value) {
|
|
28
|
-
this.cache.set(key, value, Date.now());
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.DiskCache = DiskCache;
|
|
32
|
-
//# sourceMappingURL=disk-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"disk-cache.js","sourceRoot":"","sources":["../../src/disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C,uDAA6E;AAC7E,iDAAiD;AACjD,mCAA4D;AAE5D,MAAa,SAAS;IAGpB,YACE,KAAqB,EACrB,WAAiC,uBAAe,EAChD,aAAoC,yBAAiB;QAErD,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAa,CAC5B,KAAK,EACL;YACE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACnB,EACD;YACE,QAAQ;YACR,UAAU;SACX,CACF,CAAA;IACH,CAAC;IAED,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;SAC/B;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IACxC,CAAC;CACF;AAnCD,8BAmCC"}
|
package/lib/es2015/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,4EAAyD;AACzD,oEAAiD;AACjD,+FAA4E"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IStaleIfErrorCache, State } from 'extra-memoize';
|
|
3
|
-
import { DiskCache } from 'extra-disk-cache';
|
|
4
|
-
export declare class StaleIfErrorDiskCache<T> implements IStaleIfErrorCache<T> {
|
|
5
|
-
private timeToLive;
|
|
6
|
-
private staleIfError;
|
|
7
|
-
private cache;
|
|
8
|
-
constructor(cache: DiskCache, timeToLive: number, staleIfError: number, toBuffer?: (value: T) => Buffer, fromBuffer?: (buffer: Buffer) => T);
|
|
9
|
-
get(key: string): [State.Miss] | [State.Hit | State.StaleIfError, T];
|
|
10
|
-
set(key: string, value: T): void;
|
|
11
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StaleIfErrorDiskCache = void 0;
|
|
4
|
-
const extra_memoize_1 = require("extra-memoize");
|
|
5
|
-
const extra_disk_cache_1 = require("extra-disk-cache");
|
|
6
|
-
const prelude_1 = require("@blackglory/prelude");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
class StaleIfErrorDiskCache {
|
|
9
|
-
constructor(cache, timeToLive, staleIfError, toBuffer = utils_1.defaultToBuffer, fromBuffer = utils_1.defaultFromBuffer) {
|
|
10
|
-
this.timeToLive = timeToLive;
|
|
11
|
-
this.staleIfError = staleIfError;
|
|
12
|
-
this.cache = new extra_disk_cache_1.DiskCacheView(cache, {
|
|
13
|
-
toString: x => x,
|
|
14
|
-
fromString: x => x
|
|
15
|
-
}, {
|
|
16
|
-
toBuffer,
|
|
17
|
-
fromBuffer
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
get(key) {
|
|
21
|
-
const item = this.cache.get(key);
|
|
22
|
-
if ((0, prelude_1.isUndefined)(item)) {
|
|
23
|
-
return [extra_memoize_1.State.Miss];
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
const elapsed = Date.now() - item.updatedAt;
|
|
27
|
-
if (elapsed <= this.timeToLive) {
|
|
28
|
-
return [extra_memoize_1.State.Hit, item.value];
|
|
29
|
-
}
|
|
30
|
-
else if (elapsed <= this.timeToLive + this.staleIfError) {
|
|
31
|
-
return [extra_memoize_1.State.StaleIfError, item.value];
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return [extra_memoize_1.State.Miss];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
set(key, value) {
|
|
39
|
-
this.cache.set(key, value, Date.now(), this.timeToLive + this.staleIfError);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.StaleIfErrorDiskCache = StaleIfErrorDiskCache;
|
|
43
|
-
//# sourceMappingURL=stale-if-error-async-disk-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stale-if-error-async-disk-cache.js","sourceRoot":"","sources":["../../src/stale-if-error-async-disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAAyD;AACzD,uDAA2D;AAC3D,iDAAiD;AACjD,mCAA4D;AAE5D,MAAa,qBAAqB;IAGhC,YACE,KAAgB,EACR,UAAkB,EAClB,YAAoB,EAC5B,WAAiC,uBAAe,EAChD,aAAoC,yBAAiB;QAH7C,eAAU,GAAV,UAAU,CAAQ;QAClB,iBAAY,GAAZ,YAAY,CAAQ;QAI5B,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAa,CAC5B,KAAK,EACL;YACE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACnB,EACD;YACE,QAAQ;YACR,UAAU;SACX,CACF,CAAA;IACH,CAAC;IAED,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;YAC3C,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE;gBAC9B,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAC/B;iBAAM,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE;gBACzD,OAAO,CAAC,qBAAK,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aACxC;iBAAM;gBAEL,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;aACpB;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CACZ,GAAG,EACH,KAAK,EACL,IAAI,CAAC,GAAG,EAAE,EACV,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CACpC,CAAA;IACH,CAAC;CACF;AAlDD,sDAkDC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IStaleWhileRevalidateAndStaleIfErrorCache, State } from 'extra-memoize';
|
|
3
|
-
import { DiskCache } from 'extra-disk-cache';
|
|
4
|
-
export declare class StaleWhileRevalidateAndStaleIfErrorDiskCache<T> implements IStaleWhileRevalidateAndStaleIfErrorCache<T> {
|
|
5
|
-
private timeToLive;
|
|
6
|
-
private staleWhileRevalidate;
|
|
7
|
-
private staleIfError;
|
|
8
|
-
private cache;
|
|
9
|
-
constructor(cache: DiskCache, timeToLive: number, staleWhileRevalidate: number, staleIfError: number, toBuffer?: (value: T) => Buffer, fromBuffer?: (buffer: Buffer) => T);
|
|
10
|
-
get(key: string): [State.Miss] | [State.Hit | State.StaleWhileRevalidate | State.StaleIfError, T];
|
|
11
|
-
set(key: string, value: T): void;
|
|
12
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StaleWhileRevalidateAndStaleIfErrorDiskCache = void 0;
|
|
4
|
-
const extra_memoize_1 = require("extra-memoize");
|
|
5
|
-
const extra_disk_cache_1 = require("extra-disk-cache");
|
|
6
|
-
const prelude_1 = require("@blackglory/prelude");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
class StaleWhileRevalidateAndStaleIfErrorDiskCache {
|
|
9
|
-
constructor(cache, timeToLive, staleWhileRevalidate, staleIfError, toBuffer = utils_1.defaultToBuffer, fromBuffer = utils_1.defaultFromBuffer) {
|
|
10
|
-
this.timeToLive = timeToLive;
|
|
11
|
-
this.staleWhileRevalidate = staleWhileRevalidate;
|
|
12
|
-
this.staleIfError = staleIfError;
|
|
13
|
-
this.cache = new extra_disk_cache_1.DiskCacheView(cache, {
|
|
14
|
-
toString: x => x,
|
|
15
|
-
fromString: x => x
|
|
16
|
-
}, {
|
|
17
|
-
toBuffer,
|
|
18
|
-
fromBuffer
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
get(key) {
|
|
22
|
-
const item = this.cache.get(key);
|
|
23
|
-
if ((0, prelude_1.isUndefined)(item)) {
|
|
24
|
-
return [extra_memoize_1.State.Miss];
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
const elapsed = Date.now() - item.updatedAt;
|
|
28
|
-
if (elapsed <= this.timeToLive) {
|
|
29
|
-
return [extra_memoize_1.State.Hit, item.value];
|
|
30
|
-
}
|
|
31
|
-
else if (elapsed <= this.timeToLive + this.staleWhileRevalidate) {
|
|
32
|
-
return [extra_memoize_1.State.StaleWhileRevalidate, item.value];
|
|
33
|
-
}
|
|
34
|
-
else if (elapsed <= this.timeToLive + this.staleWhileRevalidate + this.staleIfError) {
|
|
35
|
-
return [extra_memoize_1.State.StaleIfError, item.value];
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return [extra_memoize_1.State.Miss];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
set(key, value) {
|
|
43
|
-
this.cache.set(key, value, Date.now(), this.timeToLive + this.staleWhileRevalidate + this.staleIfError);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.StaleWhileRevalidateAndStaleIfErrorDiskCache = StaleWhileRevalidateAndStaleIfErrorDiskCache;
|
|
47
|
-
//# sourceMappingURL=stale-while-revalidate-and-stale-if-error-async-disk-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stale-while-revalidate-and-stale-if-error-async-disk-cache.js","sourceRoot":"","sources":["../../src/stale-while-revalidate-and-stale-if-error-async-disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAAgF;AAChF,uDAA2D;AAC3D,iDAAiD;AACjD,mCAA4D;AAE5D,MAAa,4CAA4C;IAGvD,YACE,KAAgB,EACR,UAAkB,EAClB,oBAA4B,EAC5B,YAAoB,EAC5B,WAAiC,uBAAe,EAChD,aAAoC,yBAAiB;QAJ7C,eAAU,GAAV,UAAU,CAAQ;QAClB,yBAAoB,GAApB,oBAAoB,CAAQ;QAC5B,iBAAY,GAAZ,YAAY,CAAQ;QAI5B,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAa,CAC5B,KAAK,EACL;YACE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACnB,EACD;YACE,QAAQ;YACR,UAAU;SACX,CACF,CAAA;IACH,CAAC;IAED,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;YAC3C,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE;gBAC9B,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAC/B;iBAAM,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,EAAE;gBACjE,OAAO,CAAC,qBAAK,CAAC,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAChD;iBAAM,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,YAAY,EAAE;gBACrF,OAAO,CAAC,qBAAK,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aACxC;iBAAM;gBAEL,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;aACpB;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CACZ,GAAG,EACH,KAAK,EACL,IAAI,CAAC,GAAG,EAAE,EACV,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,YAAY,CAChE,CAAA;IACH,CAAC;CACF;AArDD,oGAqDC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stale-while-revalidate-async-disk-cache.js","sourceRoot":"","sources":["../../src/stale-while-revalidate-async-disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAAiE;AACjE,uDAA2D;AAC3D,iDAAiD;AACjD,mCAA4D;AAE5D,MAAa,6BAA6B;IAGxC,YACE,KAAgB,EACR,UAAkB,EAClB,oBAA4B,EACpC,WAAiC,uBAAe,EAChD,aAAoC,yBAAiB;QAH7C,eAAU,GAAV,UAAU,CAAQ;QAClB,yBAAoB,GAApB,oBAAoB,CAAQ;QAIpC,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAa,CAC5B,KAAK,EACL;YACE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACnB,EACD;YACE,QAAQ;YACR,UAAU;SACX,CACF,CAAA;IACH,CAAC;IAED,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,IAAI,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAC/C,OAAO,CAAC,qBAAK,CAAC,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAChD;iBAAM;gBACL,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAC/B;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CACZ,GAAG,EACH,KAAK,EACL,IAAI,CAAC,GAAG,EAAE,EACV,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAC5C,CAAA;IACH,CAAC;IAEO,sBAAsB,CAAC,SAAiB;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAA;QACtC,OAAO,OAAO,GAAG,IAAI,CAAC,UAAU;eACzB,OAAO,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAA;IAC9D,CAAC;CACF;AApDD,sEAoDC"}
|
package/lib/es2015/utils.d.ts
DELETED
package/lib/es2015/utils.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultFromBuffer = exports.defaultToBuffer = void 0;
|
|
4
|
-
function defaultToBuffer(value) {
|
|
5
|
-
return Buffer.from(JSON.stringify(value));
|
|
6
|
-
}
|
|
7
|
-
exports.defaultToBuffer = defaultToBuffer;
|
|
8
|
-
function defaultFromBuffer(buffer) {
|
|
9
|
-
return JSON.parse(buffer.toString());
|
|
10
|
-
}
|
|
11
|
-
exports.defaultFromBuffer = defaultFromBuffer;
|
|
12
|
-
//# sourceMappingURL=utils.js.map
|
package/lib/es2015/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAI,KAAQ;IACzC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;AAC3C,CAAC;AAFD,0CAEC;AAED,SAAgB,iBAAiB,CAAI,MAAc;IACjD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;AACtC,CAAC;AAFD,8CAEC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ICache, State } from 'extra-memoize';
|
|
3
|
-
import { DiskCache as ExtraDiskCache } from 'extra-disk-cache';
|
|
4
|
-
export declare class DiskCache<T> implements ICache<T> {
|
|
5
|
-
private cache;
|
|
6
|
-
constructor(cache: ExtraDiskCache, toBuffer?: (value: T) => Buffer, fromBuffer?: (buffer: Buffer) => T);
|
|
7
|
-
get(key: string): [State.Miss] | [State.Hit, T];
|
|
8
|
-
set(key: string, value: T): void;
|
|
9
|
-
}
|
package/lib/es2018/disk-cache.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DiskCache = void 0;
|
|
4
|
-
const extra_memoize_1 = require("extra-memoize");
|
|
5
|
-
const extra_disk_cache_1 = require("extra-disk-cache");
|
|
6
|
-
const prelude_1 = require("@blackglory/prelude");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
class DiskCache {
|
|
9
|
-
constructor(cache, toBuffer = utils_1.defaultToBuffer, fromBuffer = utils_1.defaultFromBuffer) {
|
|
10
|
-
this.cache = new extra_disk_cache_1.DiskCacheView(cache, {
|
|
11
|
-
toString: x => x,
|
|
12
|
-
fromString: x => x
|
|
13
|
-
}, {
|
|
14
|
-
toBuffer,
|
|
15
|
-
fromBuffer
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
get(key) {
|
|
19
|
-
const item = this.cache.get(key);
|
|
20
|
-
if ((0, prelude_1.isUndefined)(item)) {
|
|
21
|
-
return [extra_memoize_1.State.Miss];
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return [extra_memoize_1.State.Hit, item.value];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
set(key, value) {
|
|
28
|
-
this.cache.set(key, value, Date.now());
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.DiskCache = DiskCache;
|
|
32
|
-
//# sourceMappingURL=disk-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"disk-cache.js","sourceRoot":"","sources":["../../src/disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C,uDAA6E;AAC7E,iDAAiD;AACjD,mCAA4D;AAE5D,MAAa,SAAS;IAGpB,YACE,KAAqB,EACrB,WAAiC,uBAAe,EAChD,aAAoC,yBAAiB;QAErD,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAa,CAC5B,KAAK,EACL;YACE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACnB,EACD;YACE,QAAQ;YACR,UAAU;SACX,CACF,CAAA;IACH,CAAC;IAED,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;SAC/B;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IACxC,CAAC;CACF;AAnCD,8BAmCC"}
|
package/lib/es2018/index.d.ts
DELETED
package/lib/es2018/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./disk-cache"), exports);
|
|
18
|
-
__exportStar(require("./stale-while-revalidate-async-disk-cache"), exports);
|
|
19
|
-
__exportStar(require("./stale-if-error-async-disk-cache"), exports);
|
|
20
|
-
__exportStar(require("./stale-while-revalidate-and-stale-if-error-async-disk-cache"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
package/lib/es2018/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,4EAAyD;AACzD,oEAAiD;AACjD,+FAA4E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stale-if-error-async-disk-cache.js","sourceRoot":"","sources":["../../src/stale-if-error-async-disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAAyD;AACzD,uDAA2D;AAC3D,iDAAiD;AACjD,mCAA4D;AAE5D,MAAa,qBAAqB;IAGhC,YACE,KAAgB,EACR,UAAkB,EAClB,YAAoB,EAC5B,WAAiC,uBAAe,EAChD,aAAoC,yBAAiB;QAH7C,eAAU,GAAV,UAAU,CAAQ;QAClB,iBAAY,GAAZ,YAAY,CAAQ;QAI5B,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAa,CAC5B,KAAK,EACL;YACE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACnB,EACD;YACE,QAAQ;YACR,UAAU;SACX,CACF,CAAA;IACH,CAAC;IAED,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;YAC3C,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE;gBAC9B,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAC/B;iBAAM,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE;gBACzD,OAAO,CAAC,qBAAK,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aACxC;iBAAM;gBAEL,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;aACpB;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CACZ,GAAG,EACH,KAAK,EACL,IAAI,CAAC,GAAG,EAAE,EACV,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CACpC,CAAA;IACH,CAAC;CACF;AAlDD,sDAkDC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stale-while-revalidate-and-stale-if-error-async-disk-cache.js","sourceRoot":"","sources":["../../src/stale-while-revalidate-and-stale-if-error-async-disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAAgF;AAChF,uDAA2D;AAC3D,iDAAiD;AACjD,mCAA4D;AAE5D,MAAa,4CAA4C;IAGvD,YACE,KAAgB,EACR,UAAkB,EAClB,oBAA4B,EAC5B,YAAoB,EAC5B,WAAiC,uBAAe,EAChD,aAAoC,yBAAiB;QAJ7C,eAAU,GAAV,UAAU,CAAQ;QAClB,yBAAoB,GAApB,oBAAoB,CAAQ;QAC5B,iBAAY,GAAZ,YAAY,CAAQ;QAI5B,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAa,CAC5B,KAAK,EACL;YACE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACnB,EACD;YACE,QAAQ;YACR,UAAU;SACX,CACF,CAAA;IACH,CAAC;IAED,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;YAC3C,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE;gBAC9B,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAC/B;iBAAM,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,EAAE;gBACjE,OAAO,CAAC,qBAAK,CAAC,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAChD;iBAAM,IAAI,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,YAAY,EAAE;gBACrF,OAAO,CAAC,qBAAK,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aACxC;iBAAM;gBAEL,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;aACpB;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CACZ,GAAG,EACH,KAAK,EACL,IAAI,CAAC,GAAG,EAAE,EACV,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,YAAY,CAChE,CAAA;IACH,CAAC;CACF;AArDD,oGAqDC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IStaleWhileRevalidateCache, State } from 'extra-memoize';
|
|
3
|
-
import { DiskCache } from 'extra-disk-cache';
|
|
4
|
-
export declare class StaleWhileRevalidateDiskCache<T> implements IStaleWhileRevalidateCache<T> {
|
|
5
|
-
private timeToLive;
|
|
6
|
-
private staleWhileRevalidate;
|
|
7
|
-
private cache;
|
|
8
|
-
constructor(cache: DiskCache, timeToLive: number, staleWhileRevalidate: number, toBuffer?: (value: T) => Buffer, fromBuffer?: (buffer: Buffer) => T);
|
|
9
|
-
get(key: string): [State.Miss] | [State.Hit | State.StaleWhileRevalidate, T];
|
|
10
|
-
set(key: string, value: T): void;
|
|
11
|
-
private isStaleWhileRevalidate;
|
|
12
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StaleWhileRevalidateDiskCache = void 0;
|
|
4
|
-
const extra_memoize_1 = require("extra-memoize");
|
|
5
|
-
const extra_disk_cache_1 = require("extra-disk-cache");
|
|
6
|
-
const prelude_1 = require("@blackglory/prelude");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
class StaleWhileRevalidateDiskCache {
|
|
9
|
-
constructor(cache, timeToLive, staleWhileRevalidate, toBuffer = utils_1.defaultToBuffer, fromBuffer = utils_1.defaultFromBuffer) {
|
|
10
|
-
this.timeToLive = timeToLive;
|
|
11
|
-
this.staleWhileRevalidate = staleWhileRevalidate;
|
|
12
|
-
this.cache = new extra_disk_cache_1.DiskCacheView(cache, {
|
|
13
|
-
toString: x => x,
|
|
14
|
-
fromString: x => x
|
|
15
|
-
}, {
|
|
16
|
-
toBuffer,
|
|
17
|
-
fromBuffer
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
get(key) {
|
|
21
|
-
const item = this.cache.get(key);
|
|
22
|
-
if ((0, prelude_1.isUndefined)(item)) {
|
|
23
|
-
return [extra_memoize_1.State.Miss];
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
if (this.isStaleWhileRevalidate(item.updatedAt)) {
|
|
27
|
-
return [extra_memoize_1.State.StaleWhileRevalidate, item.value];
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return [extra_memoize_1.State.Hit, item.value];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
set(key, value) {
|
|
35
|
-
this.cache.set(key, value, Date.now(), this.timeToLive + this.staleWhileRevalidate);
|
|
36
|
-
}
|
|
37
|
-
isStaleWhileRevalidate(updatedAt) {
|
|
38
|
-
const elapsed = Date.now() - updatedAt;
|
|
39
|
-
return elapsed > this.timeToLive
|
|
40
|
-
&& elapsed < this.timeToLive + this.staleWhileRevalidate;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.StaleWhileRevalidateDiskCache = StaleWhileRevalidateDiskCache;
|
|
44
|
-
//# sourceMappingURL=stale-while-revalidate-async-disk-cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stale-while-revalidate-async-disk-cache.js","sourceRoot":"","sources":["../../src/stale-while-revalidate-async-disk-cache.ts"],"names":[],"mappings":";;;AAAA,iDAAiE;AACjE,uDAA2D;AAC3D,iDAAiD;AACjD,mCAA4D;AAE5D,MAAa,6BAA6B;IAGxC,YACE,KAAgB,EACR,UAAkB,EAClB,oBAA4B,EACpC,WAAiC,uBAAe,EAChD,aAAoC,yBAAiB;QAH7C,eAAU,GAAV,UAAU,CAAQ;QAClB,yBAAoB,GAApB,oBAAoB,CAAQ;QAIpC,IAAI,CAAC,KAAK,GAAG,IAAI,gCAAa,CAC5B,KAAK,EACL;YACE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACnB,EACD;YACE,QAAQ;YACR,UAAU;SACX,CACF,CAAA;IACH,CAAC;IAED,GAAG,CAAC,GAAW;QAGb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE;YACrB,OAAO,CAAC,qBAAK,CAAC,IAAI,CAAC,CAAA;SACpB;aAAM;YACL,IAAI,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;gBAC/C,OAAO,CAAC,qBAAK,CAAC,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAChD;iBAAM;gBACL,OAAO,CAAC,qBAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;aAC/B;SACF;IACH,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAQ;QACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CACZ,GAAG,EACH,KAAK,EACL,IAAI,CAAC,GAAG,EAAE,EACV,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAC5C,CAAA;IACH,CAAC;IAEO,sBAAsB,CAAC,SAAiB;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAA;QACtC,OAAO,OAAO,GAAG,IAAI,CAAC,UAAU;eACzB,OAAO,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAA;IAC9D,CAAC;CACF;AApDD,sEAoDC"}
|
package/lib/es2018/utils.d.ts
DELETED
package/lib/es2018/utils.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultFromBuffer = exports.defaultToBuffer = void 0;
|
|
4
|
-
function defaultToBuffer(value) {
|
|
5
|
-
return Buffer.from(JSON.stringify(value));
|
|
6
|
-
}
|
|
7
|
-
exports.defaultToBuffer = defaultToBuffer;
|
|
8
|
-
function defaultFromBuffer(buffer) {
|
|
9
|
-
return JSON.parse(buffer.toString());
|
|
10
|
-
}
|
|
11
|
-
exports.defaultFromBuffer = defaultFromBuffer;
|
|
12
|
-
//# sourceMappingURL=utils.js.map
|
package/lib/es2018/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAI,KAAQ;IACzC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;AAC3C,CAAC;AAFD,0CAEC;AAED,SAAgB,iBAAiB,CAAI,MAAc;IACjD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;AACtC,CAAC;AAFD,8CAEC"}
|