@daysnap/utils 0.1.10 → 0.1.12

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 (52) hide show
  1. package/docs/classes/Storage.md +239 -0
  2. package/docs/interfaces/EventBusCallback.md +1 -1
  3. package/docs/interfaces/StorageManager.md +4 -4
  4. package/docs/interfaces/Trap.md +5 -5
  5. package/docs/modules.md +231 -140
  6. package/es/{chunk-3OUQEOSR.js → chunk-2SUOLGG5.js} +1 -1
  7. package/es/chunk-56QUZDMU.js +67 -0
  8. package/es/chunk-5BUZRJFA.js +19 -0
  9. package/es/{chunk-UMUYJJ3M.js → chunk-DLAUZWWO.js} +1 -1
  10. package/es/{chunk-YGYLI2DC.js → chunk-TZ2EQSRZ.js} +1 -1
  11. package/es/chunk-ZI7MCCMB.js +22 -0
  12. package/es/filterEmptyValue.js +2 -2
  13. package/es/getDateBoundsByMonths.d.ts +7 -0
  14. package/es/getDateBoundsByMonths.js +9 -0
  15. package/es/getRandom.js +2 -2
  16. package/es/getRandomNumber.js +3 -3
  17. package/es/index.d.ts +3 -0
  18. package/es/index.js +42 -30
  19. package/es/listGenerator.d.ts +1 -0
  20. package/es/listGenerator.js +1 -1
  21. package/es/storage/index.d.ts +1 -0
  22. package/es/storage/index.js +5 -1
  23. package/es/storage/storage.d.ts +40 -0
  24. package/es/storage/storage.js +8 -0
  25. package/es/withCache.d.ts +6 -0
  26. package/es/withCache.js +6 -0
  27. package/lib/{chunk-XJIRG4UL.cjs → chunk-2C3XINC3.cjs} +1 -1
  28. package/lib/chunk-2XXFQQUM.cjs +22 -0
  29. package/lib/chunk-CYZILDUJ.cjs +19 -0
  30. package/lib/chunk-GQFHHWIV.cjs +67 -0
  31. package/lib/{chunk-EJV6YDGC.cjs → chunk-IGD442DS.cjs} +2 -2
  32. package/lib/{chunk-GLLD74FC.cjs → chunk-JFPD5JTY.cjs} +2 -2
  33. package/lib/filterEmptyValue.cjs +3 -3
  34. package/lib/getDateBoundsByMonths.cjs +9 -0
  35. package/lib/getDateBoundsByMonths.d.cts +7 -0
  36. package/lib/getRandom.cjs +3 -3
  37. package/lib/getRandomNumber.cjs +4 -4
  38. package/lib/index.cjs +35 -23
  39. package/lib/index.d.cts +3 -0
  40. package/lib/listGenerator.cjs +2 -2
  41. package/lib/listGenerator.d.cts +1 -0
  42. package/lib/storage/index.cjs +6 -2
  43. package/lib/storage/index.d.cts +1 -0
  44. package/lib/storage/storage.cjs +8 -0
  45. package/lib/storage/storage.d.cts +40 -0
  46. package/lib/withCache.cjs +6 -0
  47. package/lib/withCache.d.cts +6 -0
  48. package/package.json +1 -1
  49. package/es/{chunk-IJCLLBSR.js → chunk-LG2TIXRB.js} +0 -0
  50. package/es/{chunk-4WQPAGCE.js → chunk-NXEL6RMI.js} +3 -3
  51. package/lib/{chunk-C522WKFY.cjs → chunk-2PEWYRYD.cjs} +0 -0
  52. package/lib/{chunk-6LOBB2KW.cjs → chunk-PYFTXKFI.cjs} +3 -3
@@ -0,0 +1,239 @@
1
+ [@daysnap/utils](../README.md) / [Exports](../modules.md) / Storage
2
+
3
+ # Class: Storage<T\>
4
+
5
+ ## Type parameters
6
+
7
+ | Name | Type |
8
+ | :------ | :------ |
9
+ | `T` | `any` |
10
+
11
+ ## Table of contents
12
+
13
+ ### Constructors
14
+
15
+ - [constructor](Storage.md#constructor)
16
+
17
+ ### Properties
18
+
19
+ - [key](Storage.md#key)
20
+ - [storage](Storage.md#storage)
21
+ - [value](Storage.md#value)
22
+
23
+ ### Methods
24
+
25
+ - [getItem](Storage.md#getitem)
26
+ - [getItemOnce](Storage.md#getitemonce)
27
+ - [getItemWithCache](Storage.md#getitemwithcache)
28
+ - [removeItem](Storage.md#removeitem)
29
+ - [setItem](Storage.md#setitem)
30
+ - [updateItem](Storage.md#updateitem)
31
+
32
+ ## Constructors
33
+
34
+ ### constructor
35
+
36
+ • **new Storage**<`T`\>(`key`, `storage`)
37
+
38
+ #### Type parameters
39
+
40
+ | Name | Type |
41
+ | :------ | :------ |
42
+ | `T` | `any` |
43
+
44
+ #### Parameters
45
+
46
+ | Name | Type |
47
+ | :------ | :------ |
48
+ | `key` | `string` |
49
+ | `storage` | `StorageLike` |
50
+
51
+ #### Defined in
52
+
53
+ [storage/storage.ts:15](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L15)
54
+
55
+ ## Properties
56
+
57
+ ### key
58
+
59
+ • `Private` `Readonly` **key**: `string`
60
+
61
+ #### Defined in
62
+
63
+ [storage/storage.ts:11](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L11)
64
+
65
+ ___
66
+
67
+ ### storage
68
+
69
+ • `Private` `Readonly` **storage**: `StorageLike`
70
+
71
+ #### Defined in
72
+
73
+ [storage/storage.ts:12](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L12)
74
+
75
+ ___
76
+
77
+ ### value
78
+
79
+ • `Private` **value**: ``null`` \| `T` = `null`
80
+
81
+ #### Defined in
82
+
83
+ [storage/storage.ts:13](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L13)
84
+
85
+ ## Methods
86
+
87
+ ### getItem
88
+
89
+ ▸ **getItem**(): ``null`` \| `T`
90
+
91
+ 获取值
92
+
93
+ #### Returns
94
+
95
+ ``null`` \| `T`
96
+
97
+ #### Defined in
98
+
99
+ [storage/storage.ts:32](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L32)
100
+
101
+ ▸ **getItem**(`defaultVal`): `T`
102
+
103
+ #### Parameters
104
+
105
+ | Name | Type |
106
+ | :------ | :------ |
107
+ | `defaultVal` | `Partial`<`T`\> |
108
+
109
+ #### Returns
110
+
111
+ `T`
112
+
113
+ #### Defined in
114
+
115
+ [storage/storage.ts:33](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L33)
116
+
117
+ ___
118
+
119
+ ### getItemOnce
120
+
121
+ ▸ **getItemOnce**(): ``null`` \| `T`
122
+
123
+ 获取值后,删除存储的值
124
+
125
+ #### Returns
126
+
127
+ ``null`` \| `T`
128
+
129
+ #### Defined in
130
+
131
+ [storage/storage.ts:69](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L69)
132
+
133
+ ▸ **getItemOnce**(`defaultVal`): `T`
134
+
135
+ #### Parameters
136
+
137
+ | Name | Type |
138
+ | :------ | :------ |
139
+ | `defaultVal` | `Partial`<`T`\> |
140
+
141
+ #### Returns
142
+
143
+ `T`
144
+
145
+ #### Defined in
146
+
147
+ [storage/storage.ts:70](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L70)
148
+
149
+ ___
150
+
151
+ ### getItemWithCache
152
+
153
+ ▸ **getItemWithCache**(): ``null`` \| `T`
154
+
155
+ 优先从缓存中获取值
156
+
157
+ #### Returns
158
+
159
+ ``null`` \| `T`
160
+
161
+ #### Defined in
162
+
163
+ [storage/storage.ts:85](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L85)
164
+
165
+ ▸ **getItemWithCache**(`defaultVal`): `T`
166
+
167
+ #### Parameters
168
+
169
+ | Name | Type |
170
+ | :------ | :------ |
171
+ | `defaultVal` | `Partial`<`T`\> |
172
+
173
+ #### Returns
174
+
175
+ `T`
176
+
177
+ #### Defined in
178
+
179
+ [storage/storage.ts:86](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L86)
180
+
181
+ ___
182
+
183
+ ### removeItem
184
+
185
+ ▸ **removeItem**(): `void`
186
+
187
+ 删除值
188
+
189
+ #### Returns
190
+
191
+ `void`
192
+
193
+ #### Defined in
194
+
195
+ [storage/storage.ts:45](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L45)
196
+
197
+ ___
198
+
199
+ ### setItem
200
+
201
+ ▸ **setItem**(`val`): `T`
202
+
203
+ 设置值
204
+
205
+ #### Parameters
206
+
207
+ | Name | Type |
208
+ | :------ | :------ |
209
+ | `val` | `T` |
210
+
211
+ #### Returns
212
+
213
+ `T`
214
+
215
+ #### Defined in
216
+
217
+ [storage/storage.ts:23](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L23)
218
+
219
+ ___
220
+
221
+ ### updateItem
222
+
223
+ ▸ **updateItem**(`val`): `T`
224
+
225
+ 更新值
226
+
227
+ #### Parameters
228
+
229
+ | Name | Type |
230
+ | :------ | :------ |
231
+ | `val` | `Partial`<`T`\> |
232
+
233
+ #### Returns
234
+
235
+ `T`
236
+
237
+ #### Defined in
238
+
239
+ [storage/storage.ts:53](https://github.com/daysnap/utils/blob/72518b4/src/storage/storage.ts#L53)
@@ -20,4 +20,4 @@
20
20
 
21
21
  #### Defined in
22
22
 
23
- [eventBus.ts:2](https://github.com/daysnap/utils/blob/e725a33/src/eventBus.ts#L2)
23
+ [eventBus.ts:2](https://github.com/daysnap/utils/blob/72518b4/src/eventBus.ts#L2)
@@ -35,7 +35,7 @@
35
35
 
36
36
  #### Defined in
37
37
 
38
- [storage/factory.ts:6](https://github.com/daysnap/utils/blob/e725a33/src/storage/factory.ts#L6)
38
+ [storage/factory.ts:6](https://github.com/daysnap/utils/blob/72518b4/src/storage/factory.ts#L6)
39
39
 
40
40
  ___
41
41
 
@@ -49,7 +49,7 @@ ___
49
49
 
50
50
  #### Defined in
51
51
 
52
- [storage/factory.ts:7](https://github.com/daysnap/utils/blob/e725a33/src/storage/factory.ts#L7)
52
+ [storage/factory.ts:7](https://github.com/daysnap/utils/blob/72518b4/src/storage/factory.ts#L7)
53
53
 
54
54
  ___
55
55
 
@@ -69,7 +69,7 @@ ___
69
69
 
70
70
  #### Defined in
71
71
 
72
- [storage/factory.ts:5](https://github.com/daysnap/utils/blob/e725a33/src/storage/factory.ts#L5)
72
+ [storage/factory.ts:5](https://github.com/daysnap/utils/blob/72518b4/src/storage/factory.ts#L5)
73
73
 
74
74
  ___
75
75
 
@@ -89,4 +89,4 @@ ___
89
89
 
90
90
  #### Defined in
91
91
 
92
- [storage/factory.ts:8](https://github.com/daysnap/utils/blob/e725a33/src/storage/factory.ts#L8)
92
+ [storage/factory.ts:8](https://github.com/daysnap/utils/blob/72518b4/src/storage/factory.ts#L8)
@@ -31,7 +31,7 @@
31
31
 
32
32
  #### Defined in
33
33
 
34
- [trap.ts:12](https://github.com/daysnap/utils/blob/e725a33/src/trap.ts#L12)
34
+ [trap.ts:12](https://github.com/daysnap/utils/blob/72518b4/src/trap.ts#L12)
35
35
 
36
36
  ___
37
37
 
@@ -56,7 +56,7 @@ ___
56
56
 
57
57
  #### Defined in
58
58
 
59
- [trap.ts:10](https://github.com/daysnap/utils/blob/e725a33/src/trap.ts#L10)
59
+ [trap.ts:10](https://github.com/daysnap/utils/blob/72518b4/src/trap.ts#L10)
60
60
 
61
61
  ___
62
62
 
@@ -80,7 +80,7 @@ ___
80
80
 
81
81
  #### Defined in
82
82
 
83
- [trap.ts:11](https://github.com/daysnap/utils/blob/e725a33/src/trap.ts#L11)
83
+ [trap.ts:11](https://github.com/daysnap/utils/blob/72518b4/src/trap.ts#L11)
84
84
 
85
85
  ___
86
86
 
@@ -90,7 +90,7 @@ ___
90
90
 
91
91
  #### Defined in
92
92
 
93
- [trap.ts:8](https://github.com/daysnap/utils/blob/e725a33/src/trap.ts#L8)
93
+ [trap.ts:8](https://github.com/daysnap/utils/blob/72518b4/src/trap.ts#L8)
94
94
 
95
95
  ___
96
96
 
@@ -115,4 +115,4 @@ ___
115
115
 
116
116
  #### Defined in
117
117
 
118
- [trap.ts:9](https://github.com/daysnap/utils/blob/e725a33/src/trap.ts#L9)
118
+ [trap.ts:9](https://github.com/daysnap/utils/blob/72518b4/src/trap.ts#L9)