@daysnap/utils 0.1.11 → 0.1.13

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 (74) 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 +203 -141
  6. package/es/{chunk-3OUQEOSR.js → chunk-2SUOLGG5.js} +1 -1
  7. package/es/chunk-56QUZDMU.js +67 -0
  8. package/es/{chunk-NOT3VNHC.js → chunk-A3YS6665.js} +5 -1
  9. package/es/{chunk-UMUYJJ3M.js → chunk-DLAUZWWO.js} +1 -1
  10. package/es/chunk-HNKJXGCC.js +19 -0
  11. package/es/{chunk-HREC4YYI.js → chunk-JZKIIY3L.js} +2 -2
  12. package/es/{chunk-3IKNCOC3.js → chunk-ORI5P5UA.js} +2 -2
  13. package/es/{chunk-KG436SDV.js → chunk-PSACVUUL.js} +1 -1
  14. package/es/{chunk-EY27J7WJ.js → chunk-S6ZV2M6N.js} +1 -1
  15. package/es/{chunk-YGYLI2DC.js → chunk-TZ2EQSRZ.js} +1 -1
  16. package/es/{chunk-I65EJPPI.js → chunk-UMJU7UF2.js} +1 -1
  17. package/es/{chunk-PE43T234.js → chunk-WXD7J2FR.js} +2 -2
  18. package/es/filterEmptyValue.js +2 -2
  19. package/es/formartDateToZN.js +3 -3
  20. package/es/formatDate.js +2 -2
  21. package/es/getDateBoundsByMonths.d.ts +7 -0
  22. package/es/getDateBoundsByMonths.js +9 -0
  23. package/es/getMonthBounds.js +3 -3
  24. package/es/getRandom.js +2 -2
  25. package/es/getRandomNumber.js +3 -3
  26. package/es/getRangeDate.js +3 -3
  27. package/es/getWeekday.js +2 -2
  28. package/es/index.d.ts +2 -0
  29. package/es/index.js +45 -37
  30. package/es/isValidDate.js +2 -2
  31. package/es/listGenerator.d.ts +1 -0
  32. package/es/listGenerator.js +1 -1
  33. package/es/normalizeDate.js +1 -1
  34. package/es/storage/index.d.ts +1 -0
  35. package/es/storage/index.js +5 -1
  36. package/es/storage/storage.d.ts +40 -0
  37. package/es/storage/storage.js +8 -0
  38. package/lib/{chunk-XJIRG4UL.cjs → chunk-2C3XINC3.cjs} +1 -1
  39. package/lib/chunk-44UMWNOZ.cjs +19 -0
  40. package/lib/{chunk-P3BVNREA.cjs → chunk-6TABJ32L.cjs} +2 -2
  41. package/lib/{chunk-BPNPYUBR.cjs → chunk-BQ7SLF6C.cjs} +2 -2
  42. package/lib/chunk-GQFHHWIV.cjs +67 -0
  43. package/lib/{chunk-RTTG26O5.cjs → chunk-HEVW5ZN2.cjs} +5 -1
  44. package/lib/{chunk-EJV6YDGC.cjs → chunk-IGD442DS.cjs} +2 -2
  45. package/lib/{chunk-GLLD74FC.cjs → chunk-JFPD5JTY.cjs} +2 -2
  46. package/lib/{chunk-CANF5KF5.cjs → chunk-KT3FWGJG.cjs} +4 -4
  47. package/lib/{chunk-2DCEWABW.cjs → chunk-NEFFCHO5.cjs} +5 -5
  48. package/lib/{chunk-LJYE7HIT.cjs → chunk-SOBKBDEC.cjs} +2 -2
  49. package/lib/{chunk-ELDXB7BZ.cjs → chunk-SZOUFWPJ.cjs} +4 -4
  50. package/lib/filterEmptyValue.cjs +3 -3
  51. package/lib/formartDateToZN.cjs +4 -4
  52. package/lib/formatDate.cjs +3 -3
  53. package/lib/getDateBoundsByMonths.cjs +9 -0
  54. package/lib/getDateBoundsByMonths.d.cts +7 -0
  55. package/lib/getMonthBounds.cjs +4 -4
  56. package/lib/getRandom.cjs +3 -3
  57. package/lib/getRandomNumber.cjs +4 -4
  58. package/lib/getRangeDate.cjs +4 -4
  59. package/lib/getWeekday.cjs +3 -3
  60. package/lib/index.cjs +38 -30
  61. package/lib/index.d.cts +2 -0
  62. package/lib/isValidDate.cjs +3 -3
  63. package/lib/listGenerator.cjs +2 -2
  64. package/lib/listGenerator.d.cts +1 -0
  65. package/lib/normalizeDate.cjs +2 -2
  66. package/lib/storage/index.cjs +6 -2
  67. package/lib/storage/index.d.cts +1 -0
  68. package/lib/storage/storage.cjs +8 -0
  69. package/lib/storage/storage.d.cts +40 -0
  70. package/package.json +1 -1
  71. package/es/{chunk-IJCLLBSR.js → chunk-LG2TIXRB.js} +0 -0
  72. package/es/{chunk-4WQPAGCE.js → chunk-NXEL6RMI.js} +3 -3
  73. package/lib/{chunk-C522WKFY.cjs → chunk-2PEWYRYD.cjs} +0 -0
  74. package/lib/{chunk-6LOBB2KW.cjs → chunk-PYFTXKFI.cjs} +3 -3
@@ -1,8 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkLJYE7HITcjs = require('./chunk-LJYE7HIT.cjs');
4
- require('./chunk-RTTG26O5.cjs');
3
+ var _chunkSOBKBDECcjs = require('./chunk-SOBKBDEC.cjs');
4
+ require('./chunk-HEVW5ZN2.cjs');
5
5
  require('./chunk-T5JI3MEC.cjs');
6
6
 
7
7
 
8
- exports.isValidDate = _chunkLJYE7HITcjs.isValidDate;
8
+ exports.isValidDate = _chunkSOBKBDECcjs.isValidDate;
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkXJIRG4ULcjs = require('./chunk-XJIRG4UL.cjs');
3
+ var _chunk2C3XINC3cjs = require('./chunk-2C3XINC3.cjs');
4
4
 
5
5
 
6
- exports.listGenerator = _chunkXJIRG4ULcjs.listGenerator;
6
+ exports.listGenerator = _chunk2C3XINC3cjs.listGenerator;
@@ -2,6 +2,7 @@
2
2
  * list 生成器,快速生成数据
3
3
  * @param length 个数
4
4
  */
5
+ declare function listGenerator(length: number): number[];
5
6
  declare function listGenerator<T = any>(length: number, fn: (index: number) => T): T[];
6
7
 
7
8
  export { listGenerator };
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkRTTG26O5cjs = require('./chunk-RTTG26O5.cjs');
3
+ var _chunkHEVW5ZN2cjs = require('./chunk-HEVW5ZN2.cjs');
4
4
  require('./chunk-T5JI3MEC.cjs');
5
5
 
6
6
 
7
- exports.normalizeDate = _chunkRTTG26O5cjs.normalizeDate;
7
+ exports.normalizeDate = _chunkHEVW5ZN2cjs.normalizeDate;
@@ -1,14 +1,18 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkC522WKFYcjs = require('../chunk-C522WKFY.cjs');
4
+ var _chunk2PEWYRYDcjs = require('../chunk-2PEWYRYD.cjs');
5
5
 
6
6
 
7
7
  var _chunk4YOKT62Rcjs = require('../chunk-4YOKT62R.cjs');
8
+
9
+
10
+ var _chunkGQFHHWIVcjs = require('../chunk-GQFHHWIV.cjs');
8
11
  require('../chunk-5PB5B4HH.cjs');
9
12
  require('../chunk-OSEQ7XR6.cjs');
10
13
 
11
14
 
12
15
 
13
16
 
14
- exports.factory = _chunk4YOKT62Rcjs.factory; exports.getCache = _chunkC522WKFYcjs.getCache; exports.getLocal = _chunkC522WKFYcjs.getLocal;
17
+
18
+ exports.Storage = _chunkGQFHHWIVcjs.Storage; exports.factory = _chunk4YOKT62Rcjs.factory; exports.getCache = _chunk2PEWYRYDcjs.getCache; exports.getLocal = _chunk2PEWYRYDcjs.getLocal;
@@ -1,4 +1,5 @@
1
1
  export { StorageManager, factory } from './factory.cjs';
2
+ export { Storage } from './storage.cjs';
2
3
 
3
4
  declare const getCache: () => {
4
5
  setItem: <T = any>(key: string, val: T) => T;
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkGQFHHWIVcjs = require('../chunk-GQFHHWIV.cjs');
4
+ require('../chunk-5PB5B4HH.cjs');
5
+ require('../chunk-OSEQ7XR6.cjs');
6
+
7
+
8
+ exports.Storage = _chunkGQFHHWIVcjs.Storage;
@@ -0,0 +1,40 @@
1
+ interface StorageLike {
2
+ getItem: (key: string) => string | null;
3
+ setItem: (key: string, value: string) => void;
4
+ removeItem: (key: string) => void;
5
+ }
6
+ declare class Storage<T = any> {
7
+ private readonly key;
8
+ private readonly storage;
9
+ private value;
10
+ constructor(key: string, storage: StorageLike);
11
+ /**
12
+ * 设置值
13
+ */
14
+ setItem(val: T): T;
15
+ /**
16
+ * 获取值
17
+ */
18
+ getItem(): T | null;
19
+ getItem(defaultVal: Partial<T>): T;
20
+ /**
21
+ * 删除值
22
+ */
23
+ removeItem(): void;
24
+ /**
25
+ * 更新值
26
+ */
27
+ updateItem(val: Partial<T>): T;
28
+ /**
29
+ * 获取值后,删除存储的值
30
+ */
31
+ getItemOnce(): T | null;
32
+ getItemOnce(defaultVal: Partial<T>): T;
33
+ /**
34
+ * 优先从缓存中获取值
35
+ */
36
+ getItemWithCache(): T | null;
37
+ getItemWithCache(defaultVal: Partial<T>): T;
38
+ }
39
+
40
+ export { Storage };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@daysnap/utils",
3
3
  "type": "module",
4
- "version": "0.1.11",
4
+ "version": "0.1.13",
5
5
  "description": "通用的工具库",
6
6
  "exports": {
7
7
  ".": {
File without changes
@@ -1,3 +1,6 @@
1
+ import {
2
+ isEmptyObject
3
+ } from "./chunk-GVYBTJDA.js";
1
4
  import {
2
5
  isFunction
3
6
  } from "./chunk-WCZPEH7E.js";
@@ -7,9 +10,6 @@ import {
7
10
  import {
8
11
  isEmptyArray
9
12
  } from "./chunk-ELR2DZ56.js";
10
- import {
11
- isEmptyObject
12
- } from "./chunk-GVYBTJDA.js";
13
13
  import {
14
14
  isObject
15
15
  } from "./chunk-XCSSSEK2.js";
File without changes
@@ -1,5 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
+ var _chunk5XVQSGWZcjs = require('./chunk-5XVQSGWZ.cjs');
4
+
5
+
3
6
  var _chunkOHDNJMMWcjs = require('./chunk-OHDNJMMW.cjs');
4
7
 
5
8
 
@@ -9,9 +12,6 @@ var _chunkA2J34A3Kcjs = require('./chunk-A2J34A3K.cjs');
9
12
  var _chunkX3A4TUQLcjs = require('./chunk-X3A4TUQL.cjs');
10
13
 
11
14
 
12
- var _chunk5XVQSGWZcjs = require('./chunk-5XVQSGWZ.cjs');
13
-
14
-
15
15
  var _chunkOSEQ7XR6cjs = require('./chunk-OSEQ7XR6.cjs');
16
16
 
17
17
  // src/filterEmptyValue.ts