@naturalcycles/js-lib 14.219.1 → 14.220.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/dist/decorators/memo.util.d.ts +10 -3
- package/dist/object/object.util.js +1 -1
- package/dist/string/string.util.js +2 -2
- package/dist-esm/object/object.util.js +1 -1
- package/dist-esm/string/string.util.js +2 -2
- package/package.json +1 -1
- package/src/decorators/memo.util.ts +11 -3
- package/src/object/object.util.ts +1 -1
- package/src/string/string.util.ts +2 -2
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { MISS } from '..';
|
|
1
|
+
import { MISS, UnixTimestampNumber } from '..';
|
|
2
2
|
export type MemoSerializer = (args: any[]) => any;
|
|
3
3
|
export declare const jsonMemoSerializer: MemoSerializer;
|
|
4
|
+
export interface MemoCacheOptions {
|
|
5
|
+
/**
|
|
6
|
+
* If set (and if it's implemented by the driver) - will set expiry TTL for each key of the batch.
|
|
7
|
+
* E.g EXAT in Redis.
|
|
8
|
+
*/
|
|
9
|
+
expireAt?: UnixTimestampNumber;
|
|
10
|
+
}
|
|
4
11
|
export interface MemoCache<KEY = any, VALUE = any> {
|
|
5
12
|
has: (k: KEY) => boolean;
|
|
6
13
|
/**
|
|
@@ -10,7 +17,7 @@ export interface MemoCache<KEY = any, VALUE = any> {
|
|
|
10
17
|
* Cache misses are checked by calling `has` method instead.
|
|
11
18
|
*/
|
|
12
19
|
get: (k: KEY) => VALUE;
|
|
13
|
-
set: (k: KEY, v: VALUE) => void;
|
|
20
|
+
set: (k: KEY, v: VALUE, opt?: MemoCacheOptions) => void;
|
|
14
21
|
/**
|
|
15
22
|
* Clear is only called when `_getMemoCache().clear()` is called.
|
|
16
23
|
* Otherwise the Cache is "persistent" (never cleared).
|
|
@@ -24,7 +31,7 @@ export interface AsyncMemoCache<KEY = any, VALUE = any> {
|
|
|
24
31
|
* they will not be interpreted as a cache miss, because there is a special MISS symbol for that.
|
|
25
32
|
*/
|
|
26
33
|
get: (k: KEY) => Promise<VALUE | typeof MISS>;
|
|
27
|
-
set: (k: KEY, v: VALUE) => Promise<void>;
|
|
34
|
+
set: (k: KEY, v: VALUE, opt?: MemoCacheOptions) => Promise<void>;
|
|
28
35
|
/**
|
|
29
36
|
* Clear is only called when `_getAsyncMemo().clear()` is called.
|
|
30
37
|
* Otherwise the Cache is "persistent" (never cleared).
|
|
@@ -263,7 +263,7 @@ function _unset(obj, prop) {
|
|
|
263
263
|
last = segs.pop().slice(0, -1) + '.' + last;
|
|
264
264
|
}
|
|
265
265
|
while (segs.length && (0, is_util_1._isObject)(obj)) {
|
|
266
|
-
const k =
|
|
266
|
+
const k = segs.shift();
|
|
267
267
|
obj = obj[k];
|
|
268
268
|
}
|
|
269
269
|
if (!(0, is_util_1._isObject)(obj))
|
|
@@ -71,12 +71,12 @@ function _substringBeforeLast(s, delimiter) {
|
|
|
71
71
|
exports._substringBeforeLast = _substringBeforeLast;
|
|
72
72
|
function _substringAfter(s, delimiter) {
|
|
73
73
|
const pos = s.indexOf(delimiter);
|
|
74
|
-
return pos !== -1 ? s.slice(pos +
|
|
74
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s;
|
|
75
75
|
}
|
|
76
76
|
exports._substringAfter = _substringAfter;
|
|
77
77
|
function _substringAfterLast(s, delimiter) {
|
|
78
78
|
const pos = s.lastIndexOf(delimiter);
|
|
79
|
-
return pos !== -1 ? s.slice(pos +
|
|
79
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s;
|
|
80
80
|
}
|
|
81
81
|
exports._substringAfterLast = _substringAfterLast;
|
|
82
82
|
/**
|
|
@@ -59,11 +59,11 @@ export function _substringBeforeLast(s, delimiter) {
|
|
|
59
59
|
}
|
|
60
60
|
export function _substringAfter(s, delimiter) {
|
|
61
61
|
const pos = s.indexOf(delimiter);
|
|
62
|
-
return pos !== -1 ? s.slice(pos +
|
|
62
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s;
|
|
63
63
|
}
|
|
64
64
|
export function _substringAfterLast(s, delimiter) {
|
|
65
65
|
const pos = s.lastIndexOf(delimiter);
|
|
66
|
-
return pos !== -1 ? s.slice(pos +
|
|
66
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Returns the substring between LAST `leftDelimiter` and then FIRST `rightDelimiter`.
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _isPrimitive, MISS, pDelay } from '..'
|
|
1
|
+
import { _isPrimitive, MISS, pDelay, UnixTimestampNumber } from '..'
|
|
2
2
|
|
|
3
3
|
export type MemoSerializer = (args: any[]) => any
|
|
4
4
|
|
|
@@ -8,6 +8,14 @@ export const jsonMemoSerializer: MemoSerializer = args => {
|
|
|
8
8
|
return JSON.stringify(args)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export interface MemoCacheOptions {
|
|
12
|
+
/**
|
|
13
|
+
* If set (and if it's implemented by the driver) - will set expiry TTL for each key of the batch.
|
|
14
|
+
* E.g EXAT in Redis.
|
|
15
|
+
*/
|
|
16
|
+
expireAt?: UnixTimestampNumber
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
export interface MemoCache<KEY = any, VALUE = any> {
|
|
12
20
|
has: (k: KEY) => boolean
|
|
13
21
|
/**
|
|
@@ -17,7 +25,7 @@ export interface MemoCache<KEY = any, VALUE = any> {
|
|
|
17
25
|
* Cache misses are checked by calling `has` method instead.
|
|
18
26
|
*/
|
|
19
27
|
get: (k: KEY) => VALUE
|
|
20
|
-
set: (k: KEY, v: VALUE) => void
|
|
28
|
+
set: (k: KEY, v: VALUE, opt?: MemoCacheOptions) => void
|
|
21
29
|
|
|
22
30
|
/**
|
|
23
31
|
* Clear is only called when `_getMemoCache().clear()` is called.
|
|
@@ -35,7 +43,7 @@ export interface AsyncMemoCache<KEY = any, VALUE = any> {
|
|
|
35
43
|
* they will not be interpreted as a cache miss, because there is a special MISS symbol for that.
|
|
36
44
|
*/
|
|
37
45
|
get: (k: KEY) => Promise<VALUE | typeof MISS>
|
|
38
|
-
set: (k: KEY, v: VALUE) => Promise<void>
|
|
46
|
+
set: (k: KEY, v: VALUE, opt?: MemoCacheOptions) => Promise<void>
|
|
39
47
|
|
|
40
48
|
/**
|
|
41
49
|
* Clear is only called when `_getAsyncMemo().clear()` is called.
|
|
@@ -289,7 +289,7 @@ export function _unset<T extends AnyObject>(obj: T, prop: string): void {
|
|
|
289
289
|
last = segs.pop()!.slice(0, -1) + '.' + last
|
|
290
290
|
}
|
|
291
291
|
while (segs.length && _isObject(obj)) {
|
|
292
|
-
const k =
|
|
292
|
+
const k = segs.shift()!
|
|
293
293
|
obj = obj[k]
|
|
294
294
|
}
|
|
295
295
|
if (!_isObject(obj)) return
|
|
@@ -65,12 +65,12 @@ export function _substringBeforeLast(s: string, delimiter: string): string {
|
|
|
65
65
|
|
|
66
66
|
export function _substringAfter(s: string, delimiter: string): string {
|
|
67
67
|
const pos = s.indexOf(delimiter)
|
|
68
|
-
return pos !== -1 ? s.slice(pos +
|
|
68
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function _substringAfterLast(s: string, delimiter: string): string {
|
|
72
72
|
const pos = s.lastIndexOf(delimiter)
|
|
73
|
-
return pos !== -1 ? s.slice(pos +
|
|
73
|
+
return pos !== -1 ? s.slice(pos + delimiter.length) : s
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|