@rxap/ngx-memory 21.0.1-dev.1 → 22.0.0-dev.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/CHANGELOG.md +8 -0
- package/compodoc/changelog.html +4 -0
- package/compodoc/dependencies.html +2 -2
- package/compodoc/js/search/search_index.js +2 -2
- package/compodoc/properties.html +1 -1
- package/docs/documentation.json +101 -157
- package/docs/html/classes/EphemeralStorageService.html +3 -3
- package/docs/html/classes/LocalStorageService.html +3 -3
- package/docs/html/classes/MockStorage.html +8 -8
- package/docs/html/classes/SessionStorageService.html +3 -3
- package/docs/html/classes/StorageService.html +3 -3
- package/docs/html/functions/LocalStorage.html +2 -2
- package/docs/html/functions/SessionStorage.html +2 -2
- package/docs/html/functions/StorageGet.html +1 -1
- package/docs/html/functions/StorageHas.html +1 -1
- package/docs/html/functions/StorageKey.html +1 -1
- package/docs/html/functions/StorageRemove.html +1 -1
- package/docs/html/functions/StorageSet.html +1 -1
- package/docs/html/functions/WebStorage.html +1 -1
- package/docs/html/functions/getExpired.html +1 -1
- package/docs/html/functions/stringify.html +1 -1
- package/docs/html/hierarchy.html +1 -1
- package/docs/html/index.html +2 -2
- package/docs/html/modules.html +1 -1
- package/docs/html/types/ExpiredUnit.html +2 -2
- package/docs/html/variables/isBrowser.html +2 -2
- package/docs/markdown/README.md +1 -1
- package/docs/markdown/classes/EphemeralStorageService.md +8 -8
- package/docs/markdown/classes/LocalStorageService.md +8 -8
- package/docs/markdown/classes/MockStorage.md +15 -15
- package/docs/markdown/classes/SessionStorageService.md +8 -8
- package/docs/markdown/classes/StorageService.md +8 -8
- package/docs/markdown/functions/LocalStorage.md +2 -2
- package/docs/markdown/functions/SessionStorage.md +2 -2
- package/docs/markdown/functions/StorageGet.md +2 -2
- package/docs/markdown/functions/StorageHas.md +2 -2
- package/docs/markdown/functions/StorageKey.md +2 -2
- package/docs/markdown/functions/StorageRemove.md +2 -2
- package/docs/markdown/functions/StorageSet.md +2 -2
- package/docs/markdown/functions/WebStorage.md +2 -2
- package/docs/markdown/functions/getExpired.md +2 -2
- package/docs/markdown/functions/stringify.md +2 -2
- package/docs/markdown/globals.md +2 -2
- package/docs/markdown/type-aliases/ExpiredUnit.md +2 -2
- package/docs/markdown/variables/isBrowser.md +2 -2
- package/docs/wiki/Class.EphemeralStorageService.md +7 -7
- package/docs/wiki/Class.LocalStorageService.md +7 -7
- package/docs/wiki/Class.MockStorage.md +14 -14
- package/docs/wiki/Class.SessionStorageService.md +7 -7
- package/docs/wiki/Class.StorageService.md +7 -7
- package/docs/wiki/Function.LocalStorage.md +1 -1
- package/docs/wiki/Function.SessionStorage.md +1 -1
- package/docs/wiki/Function.StorageGet.md +1 -1
- package/docs/wiki/Function.StorageHas.md +1 -1
- package/docs/wiki/Function.StorageKey.md +1 -1
- package/docs/wiki/Function.StorageRemove.md +1 -1
- package/docs/wiki/Function.StorageSet.md +1 -1
- package/docs/wiki/Function.WebStorage.md +1 -1
- package/docs/wiki/Function.getExpired.md +1 -1
- package/docs/wiki/Function.stringify.md +1 -1
- package/docs/wiki/TypeAlias.ExpiredUnit.md +1 -1
- package/docs/wiki/Variable.isBrowser.md +1 -1
- package/docs/wiki/globals.md +1 -1
- package/fesm2022/rxap-ngx-memory.mjs +260 -258
- package/fesm2022/rxap-ngx-memory.mjs.map +1 -1
- package/package.json +5 -5
- package/types/rxap-ngx-memory.d.ts +53 -61
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **StorageGet**(`storage`, `key`): `unknown`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:20](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:20](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/storage-utility.ts#L20)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **StorageHas**(`storage`, `key`): `boolean`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:37](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:37](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/storage-utility.ts#L37)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **StorageKey**(`storage`, `index`): `null` \| `string`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:65](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:65](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/storage-utility.ts#L65)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **StorageRemove**(`storage`, `key`): `void`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:58](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:58](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/storage-utility.ts#L58)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **StorageSet**(`storage`, `key`, `value`, `expiredAt`, `expiredUnit`): `void`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:44](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:44](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/storage-utility.ts#L44)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **WebStorage**(`storage`, `key`?, `expiredAt`?, `expiredUnit`?): (`target`, `propertyName`) => `void`
|
|
6
6
|
|
|
7
|
-
Defined in: [decorators/web-storage.ts:16](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [decorators/web-storage.ts:16](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/decorators/web-storage.ts#L16)
|
|
8
8
|
|
|
9
9
|
**`Internal`**
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **getExpired**(`val`, `unit`): `number`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:72](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:72](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/storage-utility.ts#L72)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **stringify**(`value`): `string`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:98](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:98](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/storage-utility.ts#L98)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **ExpiredUnit**: `"s"` \| `"m"` \| `"h"` \| `"d"` \| `"w"` \| `"y"` \| `"t"`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:11](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:11](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/storage-utility.ts#L11)
|
|
8
8
|
|
|
9
9
|
Expiration time unit
|
|
10
10
|
s: seconds
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> `const` **isBrowser**: `boolean`
|
|
6
6
|
|
|
7
|
-
Defined in: [storage-utility.ts:18](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [storage-utility.ts:18](https://gitlab.com/rxap/packages/-/blob/c8145693a1e685c856c9997ae6c17bbf32838e79/packages/angular/memory/src/lib/storage-utility.ts#L18)
|
|
8
8
|
|
|
9
9
|
Determining if an Angular application is rendered in the browser
|
|
10
10
|
The Angular `PLATFORM_ID` identifier cannot be used directly by the `decorator`.
|
package/docs/wiki/globals.md
CHANGED
|
@@ -1,277 +1,279 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import { Injectable } from
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Determining if an Angular application is rendered in the browser
|
|
6
|
-
* The Angular `PLATFORM_ID` identifier cannot be used directly by the `decorator`.
|
|
7
|
-
* The advantage of this is that it also works well when the server populates the Document itself.
|
|
8
|
-
*/
|
|
9
|
-
const isBrowser = typeof document === 'object' && !!document;
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Injectable } from "@angular/core";
|
|
3
|
+
const isBrowser = typeof document === "object" && !!document;
|
|
10
4
|
function StorageGet(storage, key) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
value._expired) {
|
|
20
|
-
StorageRemove(storage, key);
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return value._value ?? null;
|
|
5
|
+
if (storage === null) return null;
|
|
6
|
+
const value = parse(storage.getItem(key) ?? "null") ?? null;
|
|
7
|
+
if (value === null) return null;
|
|
8
|
+
if (typeof value === "object" && typeof value._expired !== "undefined" && value._expired !== 0 && +/* @__PURE__ */ new Date() > value._expired) {
|
|
9
|
+
StorageRemove(storage, key);
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return value._value ?? null;
|
|
24
13
|
}
|
|
25
14
|
function StorageHas(storage, key) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
return storage.getItem(key) !== null;
|
|
15
|
+
if (storage === null) return false;
|
|
16
|
+
return storage.getItem(key) !== null;
|
|
30
17
|
}
|
|
31
|
-
function StorageSet(storage, key, value, expiredAt = 0, expiredUnit =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_value: value,
|
|
38
|
-
}));
|
|
18
|
+
function StorageSet(storage, key, value, expiredAt = 0, expiredUnit = "t") {
|
|
19
|
+
if (storage === null) return;
|
|
20
|
+
storage.setItem(key, stringify({
|
|
21
|
+
_expired: getExpired(expiredAt, expiredUnit),
|
|
22
|
+
_value: value
|
|
23
|
+
}));
|
|
39
24
|
}
|
|
40
25
|
function StorageRemove(storage, key) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
storage.removeItem(key);
|
|
26
|
+
if (storage === null) return;
|
|
27
|
+
storage.removeItem(key);
|
|
45
28
|
}
|
|
46
29
|
function StorageKey(storage, index) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
return storage.key(index);
|
|
30
|
+
if (storage === null) return null;
|
|
31
|
+
return storage.key(index);
|
|
51
32
|
}
|
|
52
33
|
function getExpired(val, unit) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
case 'w': // week
|
|
67
|
-
return now + 1000 * 60 * 60 * 24 * 7 * val;
|
|
68
|
-
case 'y': // year
|
|
69
|
-
return now + 1000 * 60 * 60 * 24 * 365 * val;
|
|
70
|
-
case 't': // customisation
|
|
71
|
-
return now + val;
|
|
72
|
-
default:
|
|
73
|
-
throw new Error('Invalid expired unit');
|
|
74
|
-
}
|
|
75
|
-
return 0;
|
|
34
|
+
if (val <= 0) return 0;
|
|
35
|
+
const now = +/* @__PURE__ */ new Date();
|
|
36
|
+
switch (unit) {
|
|
37
|
+
case "s": return now + 1e3 * val;
|
|
38
|
+
case "m": return now + 6e4 * val;
|
|
39
|
+
case "h": return now + 36e5 * val;
|
|
40
|
+
case "d": return now + 864e5 * val;
|
|
41
|
+
case "w": return now + 6048e5 * val;
|
|
42
|
+
case "y": return now + 31536e6 * val;
|
|
43
|
+
case "t": return now + val;
|
|
44
|
+
default: throw new Error("Invalid expired unit");
|
|
45
|
+
}
|
|
46
|
+
return 0;
|
|
76
47
|
}
|
|
77
48
|
function stringify(value) {
|
|
78
|
-
|
|
49
|
+
return JSON.stringify(value);
|
|
79
50
|
}
|
|
80
51
|
function parse(text) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(text) ?? null;
|
|
54
|
+
} catch (e) {
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
87
57
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
58
|
+
var MockStorage = class {
|
|
59
|
+
constructor() {
|
|
60
|
+
this.cache = {};
|
|
61
|
+
}
|
|
62
|
+
get length() {
|
|
63
|
+
return Object.keys(this.cache).length;
|
|
64
|
+
}
|
|
65
|
+
getItem(key) {
|
|
66
|
+
return this.cache[key] ?? null;
|
|
67
|
+
}
|
|
68
|
+
key(index) {
|
|
69
|
+
return Object.keys(this.cache)[index] ?? null;
|
|
70
|
+
}
|
|
71
|
+
removeItem(key) {
|
|
72
|
+
if (this.cache[key] !== void 0) delete this.cache[key];
|
|
73
|
+
}
|
|
74
|
+
setItem(key, value) {
|
|
75
|
+
this.cache[key] = value;
|
|
76
|
+
}
|
|
77
|
+
clear() {
|
|
78
|
+
this.cache = {};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
function WebStorage(storage, key, expiredAt = 0, expiredUnit = "d") {
|
|
82
|
+
return (target, propertyName) => {
|
|
83
|
+
const storageKey = key ?? propertyName;
|
|
84
|
+
let propertyValue = void 0;
|
|
85
|
+
Object.defineProperty(target, propertyName, {
|
|
86
|
+
get: () => {
|
|
87
|
+
if (propertyValue === void 0) {
|
|
88
|
+
if (StorageHas(storage, storageKey)) return propertyValue = StorageGet(storage, storageKey);
|
|
89
|
+
}
|
|
90
|
+
return propertyValue;
|
|
91
|
+
},
|
|
92
|
+
set: (value) => {
|
|
93
|
+
if (propertyValue === void 0) {
|
|
94
|
+
if (StorageHas(storage, storageKey)) {
|
|
95
|
+
propertyValue = StorageGet(storage, storageKey);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
propertyValue = value;
|
|
100
|
+
if (propertyValue === void 0) {
|
|
101
|
+
if (StorageHas(storage, storageKey)) StorageRemove(storage, storageKey);
|
|
102
|
+
} else StorageSet(storage, storageKey, value, expiredAt, expiredUnit);
|
|
103
|
+
},
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true
|
|
106
|
+
});
|
|
107
|
+
};
|
|
112
108
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* @internal
|
|
116
|
-
* @param storage
|
|
117
|
-
* @param key
|
|
118
|
-
* @param expiredAt
|
|
119
|
-
* @param expiredUnit
|
|
120
|
-
*/
|
|
121
|
-
function WebStorage(storage, key, expiredAt = 0, expiredUnit = 'd') {
|
|
122
|
-
return (target, propertyName) => {
|
|
123
|
-
const storageKey = key ?? propertyName;
|
|
124
|
-
let propertyValue = undefined;
|
|
125
|
-
Object.defineProperty(target, propertyName, {
|
|
126
|
-
get: () => {
|
|
127
|
-
// check if the value is set
|
|
128
|
-
if (propertyValue === undefined) {
|
|
129
|
-
// if not check if the value is set in the storage
|
|
130
|
-
if (StorageHas(storage, storageKey)) {
|
|
131
|
-
return propertyValue = StorageGet(storage, storageKey);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return propertyValue;
|
|
135
|
-
},
|
|
136
|
-
set: (value) => {
|
|
137
|
-
// check if the value is set
|
|
138
|
-
if (propertyValue === undefined) {
|
|
139
|
-
// if not check if the value is set in the storage
|
|
140
|
-
if (StorageHas(storage, storageKey)) {
|
|
141
|
-
// if yes, get the value from the storage
|
|
142
|
-
propertyValue = StorageGet(storage, storageKey);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
propertyValue = value;
|
|
147
|
-
// check if the value is set
|
|
148
|
-
if (propertyValue === undefined) {
|
|
149
|
-
// check if the value is set in the storage
|
|
150
|
-
if (StorageHas(storage, storageKey)) {
|
|
151
|
-
// remove any value from the storage
|
|
152
|
-
StorageRemove(storage, storageKey);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
// set the value in the storage
|
|
157
|
-
StorageSet(storage, storageKey, value, expiredAt, expiredUnit);
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
enumerable: true,
|
|
161
|
-
configurable: true,
|
|
162
|
-
});
|
|
163
|
-
};
|
|
109
|
+
function LocalStorage(key, expiredAt = 0, expiredUnit = "t") {
|
|
110
|
+
return WebStorage(isBrowser ? localStorage : null, key, expiredAt, expiredUnit);
|
|
164
111
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
* `localStorage` Decorator
|
|
168
|
-
*
|
|
169
|
-
* @param [key] Storage key
|
|
170
|
-
* @param [expiredAt=0] Expiration time, 0 means forever
|
|
171
|
-
* @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])
|
|
172
|
-
*/
|
|
173
|
-
function LocalStorage(key, expiredAt = 0, expiredUnit = 't') {
|
|
174
|
-
return WebStorage(isBrowser ? localStorage : null, key, expiredAt, expiredUnit);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* `sessionStorage` Decorator
|
|
179
|
-
*
|
|
180
|
-
* @param [key] Storage key
|
|
181
|
-
* @param [expiredAt=0] Expiration time, 0 means forever
|
|
182
|
-
* @param [expiredUnit='t'] Expiration time unit (default: custom [unit: ms])
|
|
183
|
-
*/
|
|
184
|
-
function SessionStorage(key, expiredAt = 0, expiredUnit = 't') {
|
|
185
|
-
return WebStorage(isBrowser ? sessionStorage : null, key, expiredAt, expiredUnit);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
class StorageService {
|
|
189
|
-
constructor(storage) {
|
|
190
|
-
this.storage = storage;
|
|
191
|
-
}
|
|
192
|
-
has(key) {
|
|
193
|
-
return StorageHas(this.storage, key);
|
|
194
|
-
}
|
|
195
|
-
get(key) {
|
|
196
|
-
return StorageGet(this.storage, key);
|
|
197
|
-
}
|
|
198
|
-
set(key, value, expiredAt = 0, expiredUnit = 'd') {
|
|
199
|
-
return StorageSet(this.storage, key, value, expiredAt, expiredUnit);
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Removes the specified key, e.g.:
|
|
203
|
-
* - `remove('key')` Remove `key` key
|
|
204
|
-
* - `remove(/BMap_\w+/)` Bulk delete all keys starting with BMap_
|
|
205
|
-
* @param key key name or regular expression
|
|
206
|
-
*/
|
|
207
|
-
remove(key) {
|
|
208
|
-
if (typeof key === 'string') {
|
|
209
|
-
StorageRemove(this.storage, key);
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
let index = 0;
|
|
213
|
-
let next = StorageKey(this.storage, index);
|
|
214
|
-
const ls = [];
|
|
215
|
-
while (next) {
|
|
216
|
-
if (key.test(next)) {
|
|
217
|
-
ls.push(next);
|
|
218
|
-
}
|
|
219
|
-
next = StorageKey(this.storage, ++index);
|
|
220
|
-
}
|
|
221
|
-
ls.forEach((v) => StorageRemove(this.storage, v));
|
|
222
|
-
}
|
|
223
|
-
clear() {
|
|
224
|
-
this.storage?.clear();
|
|
225
|
-
}
|
|
226
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: StorageService, deps: [{ token: Storage }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
227
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: StorageService }); }
|
|
228
|
-
}
|
|
229
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: StorageService, decorators: [{
|
|
230
|
-
type: Injectable
|
|
231
|
-
}], ctorParameters: () => [{ type: Storage }] });
|
|
232
|
-
|
|
233
|
-
class EphemeralStorageService extends StorageService {
|
|
234
|
-
constructor() {
|
|
235
|
-
super(new MockStorage());
|
|
236
|
-
}
|
|
237
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: EphemeralStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
238
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: EphemeralStorageService, providedIn: 'root' }); }
|
|
112
|
+
function SessionStorage(key, expiredAt = 0, expiredUnit = "t") {
|
|
113
|
+
return WebStorage(isBrowser ? sessionStorage : null, key, expiredAt, expiredUnit);
|
|
239
114
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
115
|
+
var StorageService = class StorageService {
|
|
116
|
+
constructor(storage) {
|
|
117
|
+
this.storage = storage;
|
|
118
|
+
}
|
|
119
|
+
has(key) {
|
|
120
|
+
return StorageHas(this.storage, key);
|
|
121
|
+
}
|
|
122
|
+
get(key) {
|
|
123
|
+
return StorageGet(this.storage, key);
|
|
124
|
+
}
|
|
125
|
+
set(key, value, expiredAt = 0, expiredUnit = "d") {
|
|
126
|
+
return StorageSet(this.storage, key, value, expiredAt, expiredUnit);
|
|
127
|
+
}
|
|
128
|
+
remove(key) {
|
|
129
|
+
if (typeof key === "string") {
|
|
130
|
+
StorageRemove(this.storage, key);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
let index = 0;
|
|
134
|
+
let next = StorageKey(this.storage, index);
|
|
135
|
+
const ls = [];
|
|
136
|
+
while (next) {
|
|
137
|
+
if (key.test(next)) ls.push(next);
|
|
138
|
+
next = StorageKey(this.storage, ++index);
|
|
139
|
+
}
|
|
140
|
+
ls.forEach((v) => StorageRemove(this.storage, v));
|
|
141
|
+
}
|
|
142
|
+
clear() {
|
|
143
|
+
this.storage?.clear();
|
|
144
|
+
}
|
|
145
|
+
static {
|
|
146
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
147
|
+
minVersion: "12.0.0",
|
|
148
|
+
version: "22.3.0",
|
|
149
|
+
ngImport: i0,
|
|
150
|
+
type: StorageService,
|
|
151
|
+
deps: [{ token: Storage }],
|
|
152
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
static {
|
|
156
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
157
|
+
minVersion: "12.0.0",
|
|
158
|
+
version: "22.3.0",
|
|
159
|
+
ngImport: i0,
|
|
160
|
+
type: StorageService
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
165
|
+
minVersion: "12.0.0",
|
|
166
|
+
version: "22.3.0",
|
|
167
|
+
ngImport: i0,
|
|
168
|
+
type: StorageService,
|
|
169
|
+
decorators: [{ type: Injectable }],
|
|
170
|
+
ctorParameters: () => [{ type: Storage }]
|
|
171
|
+
});
|
|
172
|
+
var EphemeralStorageService = class EphemeralStorageService extends StorageService {
|
|
173
|
+
constructor() {
|
|
174
|
+
super(new MockStorage());
|
|
175
|
+
}
|
|
176
|
+
static {
|
|
177
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
178
|
+
minVersion: "12.0.0",
|
|
179
|
+
version: "22.3.0",
|
|
180
|
+
ngImport: i0,
|
|
181
|
+
type: EphemeralStorageService,
|
|
182
|
+
deps: [],
|
|
183
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
static {
|
|
187
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
188
|
+
minVersion: "12.0.0",
|
|
189
|
+
version: "22.3.0",
|
|
190
|
+
ngImport: i0,
|
|
191
|
+
type: EphemeralStorageService,
|
|
192
|
+
providedIn: "root"
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
197
|
+
minVersion: "12.0.0",
|
|
198
|
+
version: "22.3.0",
|
|
199
|
+
ngImport: i0,
|
|
200
|
+
type: EphemeralStorageService,
|
|
201
|
+
decorators: [{
|
|
202
|
+
type: Injectable,
|
|
203
|
+
args: [{ providedIn: "root" }]
|
|
204
|
+
}],
|
|
205
|
+
ctorParameters: () => []
|
|
206
|
+
});
|
|
207
|
+
var LocalStorageService = class LocalStorageService extends StorageService {
|
|
208
|
+
constructor() {
|
|
209
|
+
super(isBrowser ? localStorage : null);
|
|
210
|
+
}
|
|
211
|
+
static {
|
|
212
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
213
|
+
minVersion: "12.0.0",
|
|
214
|
+
version: "22.3.0",
|
|
215
|
+
ngImport: i0,
|
|
216
|
+
type: LocalStorageService,
|
|
217
|
+
deps: [],
|
|
218
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
static {
|
|
222
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
223
|
+
minVersion: "12.0.0",
|
|
224
|
+
version: "22.3.0",
|
|
225
|
+
ngImport: i0,
|
|
226
|
+
type: LocalStorageService,
|
|
227
|
+
providedIn: "root"
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
232
|
+
minVersion: "12.0.0",
|
|
233
|
+
version: "22.3.0",
|
|
234
|
+
ngImport: i0,
|
|
235
|
+
type: LocalStorageService,
|
|
236
|
+
decorators: [{
|
|
237
|
+
type: Injectable,
|
|
238
|
+
args: [{ providedIn: "root" }]
|
|
239
|
+
}],
|
|
240
|
+
ctorParameters: () => []
|
|
241
|
+
});
|
|
242
|
+
var SessionStorageService = class SessionStorageService extends StorageService {
|
|
243
|
+
constructor() {
|
|
244
|
+
super(isBrowser ? sessionStorage : null);
|
|
245
|
+
}
|
|
246
|
+
static {
|
|
247
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
248
|
+
minVersion: "12.0.0",
|
|
249
|
+
version: "22.3.0",
|
|
250
|
+
ngImport: i0,
|
|
251
|
+
type: SessionStorageService,
|
|
252
|
+
deps: [],
|
|
253
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
static {
|
|
257
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
258
|
+
minVersion: "12.0.0",
|
|
259
|
+
version: "22.3.0",
|
|
260
|
+
ngImport: i0,
|
|
261
|
+
type: SessionStorageService,
|
|
262
|
+
providedIn: "root"
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
267
|
+
minVersion: "12.0.0",
|
|
268
|
+
version: "22.3.0",
|
|
269
|
+
ngImport: i0,
|
|
270
|
+
type: SessionStorageService,
|
|
271
|
+
decorators: [{
|
|
272
|
+
type: Injectable,
|
|
273
|
+
args: [{ providedIn: "root" }]
|
|
274
|
+
}],
|
|
275
|
+
ctorParameters: () => []
|
|
276
|
+
});
|
|
276
277
|
export { EphemeralStorageService, LocalStorage, LocalStorageService, MockStorage, SessionStorage, SessionStorageService, StorageGet, StorageHas, StorageKey, StorageRemove, StorageService, StorageSet, WebStorage, getExpired, isBrowser, stringify };
|
|
277
|
-
|
|
278
|
+
|
|
279
|
+
//# sourceMappingURL=rxap-ngx-memory.mjs.map
|