@rxap/ngx-memory 21.0.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/compodoc/changelog.html +2 -0
  3. package/compodoc/dependencies.html +2 -2
  4. package/compodoc/js/search/search_index.js +2 -2
  5. package/compodoc/properties.html +1 -1
  6. package/docs/documentation.json +101 -157
  7. package/docs/html/classes/EphemeralStorageService.html +3 -3
  8. package/docs/html/classes/LocalStorageService.html +3 -3
  9. package/docs/html/classes/MockStorage.html +8 -8
  10. package/docs/html/classes/SessionStorageService.html +3 -3
  11. package/docs/html/classes/StorageService.html +3 -3
  12. package/docs/html/functions/LocalStorage.html +2 -2
  13. package/docs/html/functions/SessionStorage.html +2 -2
  14. package/docs/html/functions/StorageGet.html +1 -1
  15. package/docs/html/functions/StorageHas.html +1 -1
  16. package/docs/html/functions/StorageKey.html +1 -1
  17. package/docs/html/functions/StorageRemove.html +1 -1
  18. package/docs/html/functions/StorageSet.html +1 -1
  19. package/docs/html/functions/WebStorage.html +1 -1
  20. package/docs/html/functions/getExpired.html +1 -1
  21. package/docs/html/functions/stringify.html +1 -1
  22. package/docs/html/hierarchy.html +1 -1
  23. package/docs/html/index.html +2 -2
  24. package/docs/html/modules.html +1 -1
  25. package/docs/html/types/ExpiredUnit.html +2 -2
  26. package/docs/html/variables/isBrowser.html +2 -2
  27. package/docs/markdown/README.md +1 -1
  28. package/docs/markdown/classes/EphemeralStorageService.md +8 -8
  29. package/docs/markdown/classes/LocalStorageService.md +8 -8
  30. package/docs/markdown/classes/MockStorage.md +15 -15
  31. package/docs/markdown/classes/SessionStorageService.md +8 -8
  32. package/docs/markdown/classes/StorageService.md +8 -8
  33. package/docs/markdown/functions/LocalStorage.md +2 -2
  34. package/docs/markdown/functions/SessionStorage.md +2 -2
  35. package/docs/markdown/functions/StorageGet.md +2 -2
  36. package/docs/markdown/functions/StorageHas.md +2 -2
  37. package/docs/markdown/functions/StorageKey.md +2 -2
  38. package/docs/markdown/functions/StorageRemove.md +2 -2
  39. package/docs/markdown/functions/StorageSet.md +2 -2
  40. package/docs/markdown/functions/WebStorage.md +2 -2
  41. package/docs/markdown/functions/getExpired.md +2 -2
  42. package/docs/markdown/functions/stringify.md +2 -2
  43. package/docs/markdown/globals.md +2 -2
  44. package/docs/markdown/type-aliases/ExpiredUnit.md +2 -2
  45. package/docs/markdown/variables/isBrowser.md +2 -2
  46. package/docs/wiki/Class.EphemeralStorageService.md +7 -7
  47. package/docs/wiki/Class.LocalStorageService.md +7 -7
  48. package/docs/wiki/Class.MockStorage.md +14 -14
  49. package/docs/wiki/Class.SessionStorageService.md +7 -7
  50. package/docs/wiki/Class.StorageService.md +7 -7
  51. package/docs/wiki/Function.LocalStorage.md +1 -1
  52. package/docs/wiki/Function.SessionStorage.md +1 -1
  53. package/docs/wiki/Function.StorageGet.md +1 -1
  54. package/docs/wiki/Function.StorageHas.md +1 -1
  55. package/docs/wiki/Function.StorageKey.md +1 -1
  56. package/docs/wiki/Function.StorageRemove.md +1 -1
  57. package/docs/wiki/Function.StorageSet.md +1 -1
  58. package/docs/wiki/Function.WebStorage.md +1 -1
  59. package/docs/wiki/Function.getExpired.md +1 -1
  60. package/docs/wiki/Function.stringify.md +1 -1
  61. package/docs/wiki/TypeAlias.ExpiredUnit.md +1 -1
  62. package/docs/wiki/Variable.isBrowser.md +1 -1
  63. package/docs/wiki/globals.md +1 -1
  64. package/fesm2022/rxap-ngx-memory.mjs +260 -258
  65. package/fesm2022/rxap-ngx-memory.mjs.map +1 -1
  66. package/package.json +5 -5
  67. 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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/storage-utility.ts#L20)
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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/storage-utility.ts#L37)
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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/storage-utility.ts#L65)
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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/storage-utility.ts#L58)
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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/storage-utility.ts#L44)
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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/decorators/web-storage.ts#L16)
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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/storage-utility.ts#L72)
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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/storage-utility.ts#L98)
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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/storage-utility.ts#L11)
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/61502283d3119c1cda051f50c92b1b3e3860adb4/packages/angular/memory/src/lib/storage-utility.ts#L18)
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`.
@@ -1,4 +1,4 @@
1
- # @rxap/ngx-memory v21.0.1
1
+ # @rxap/ngx-memory v22.0.0-dev.0
2
2
 
3
3
  ## Classes
4
4
 
@@ -1,277 +1,279 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable } from '@angular/core';
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
- if (storage === null) {
12
- return null;
13
- }
14
- const value = parse(storage.getItem(key) ?? 'null') ?? null;
15
- if (value === null) {
16
- return null;
17
- }
18
- if (typeof value === 'object' && typeof value._expired !== 'undefined' && value._expired !== 0 && +new Date() >
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
- if (storage === null) {
27
- return false;
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 = 't') {
32
- if (storage === null) {
33
- return;
34
- }
35
- storage.setItem(key, stringify({
36
- _expired: getExpired(expiredAt, expiredUnit),
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
- if (storage === null) {
42
- return;
43
- }
44
- storage.removeItem(key);
26
+ if (storage === null) return;
27
+ storage.removeItem(key);
45
28
  }
46
29
  function StorageKey(storage, index) {
47
- if (storage === null) {
48
- return null;
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
- if (val <= 0) {
54
- return 0;
55
- }
56
- const now = +new Date();
57
- switch (unit) {
58
- case 's': // second
59
- return now + 1000 * val;
60
- case 'm': // minute
61
- return now + 1000 * 60 * val;
62
- case 'h': // hour
63
- return now + 1000 * 60 * 60 * val;
64
- case 'd': // day
65
- return now + 1000 * 60 * 60 * 24 * val;
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
- return JSON.stringify(value);
49
+ return JSON.stringify(value);
79
50
  }
80
51
  function parse(text) {
81
- try {
82
- return JSON.parse(text) ?? null;
83
- }
84
- catch (e) {
85
- return text;
86
- }
52
+ try {
53
+ return JSON.parse(text) ?? null;
54
+ } catch (e) {
55
+ return text;
56
+ }
87
57
  }
88
- class MockStorage {
89
- constructor() {
90
- this.cache = {};
91
- }
92
- get length() {
93
- return Object.keys(this.cache).length;
94
- }
95
- getItem(key) {
96
- return this.cache[key] ?? null;
97
- }
98
- key(index) {
99
- return Object.keys(this.cache)[index] ?? null;
100
- }
101
- removeItem(key) {
102
- if (this.cache[key] !== undefined) {
103
- delete this.cache[key];
104
- }
105
- }
106
- setItem(key, value) {
107
- this.cache[key] = value;
108
- }
109
- clear() {
110
- this.cache = {};
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
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: EphemeralStorageService, decorators: [{
241
- type: Injectable,
242
- args: [{ providedIn: 'root' }]
243
- }], ctorParameters: () => [] });
244
-
245
- class LocalStorageService extends StorageService {
246
- constructor() {
247
- super(isBrowser ? localStorage : null);
248
- }
249
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
250
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: LocalStorageService, providedIn: 'root' }); }
251
- }
252
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: LocalStorageService, decorators: [{
253
- type: Injectable,
254
- args: [{ providedIn: 'root' }]
255
- }], ctorParameters: () => [] });
256
-
257
- class SessionStorageService extends StorageService {
258
- constructor() {
259
- super(isBrowser ? sessionStorage : null);
260
- }
261
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: SessionStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
262
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: SessionStorageService, providedIn: 'root' }); }
263
- }
264
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: SessionStorageService, decorators: [{
265
- type: Injectable,
266
- args: [{ providedIn: 'root' }]
267
- }], ctorParameters: () => [] });
268
-
269
- // region decorators
270
- // endregion
271
-
272
- /**
273
- * Generated bundle index. Do not edit.
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
- //# sourceMappingURL=rxap-ngx-memory.mjs.map
278
+
279
+ //# sourceMappingURL=rxap-ngx-memory.mjs.map