@nickyzj2023/utils 1.0.51 → 1.0.53

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 (108) hide show
  1. package/dist/dom/index.d.ts +1 -0
  2. package/dist/dom/log.d.ts +26 -0
  3. package/{src/dom/timeLog.ts → dist/dom/timeLog.d.ts} +8 -10
  4. package/dist/function/index.d.ts +1 -0
  5. package/dist/function/loop-until.d.ts +22 -0
  6. package/dist/function/loopUntil.d.ts +22 -0
  7. package/dist/hoc/index.d.ts +1 -0
  8. package/dist/hoc/with-cache.d.ts +42 -0
  9. package/dist/hoc/withCache.d.ts +42 -0
  10. package/dist/index.d.ts +9 -0
  11. package/dist/index.js +3 -0
  12. package/dist/is/index.d.ts +4 -0
  13. package/dist/is/is-falsy.d.ts +9 -0
  14. package/dist/is/is-nil.d.ts +9 -0
  15. package/dist/is/is-object.d.ts +8 -0
  16. package/dist/is/is-primitive.d.ts +9 -0
  17. package/dist/is/isFalsy.d.ts +9 -0
  18. package/dist/is/isNil.d.ts +9 -0
  19. package/dist/is/isObject.d.ts +8 -0
  20. package/dist/is/isPrimitive.d.ts +9 -0
  21. package/{src/is/isTruthy.ts → dist/is/isTruthy.d.ts} +8 -10
  22. package/dist/lru-cache.d.ts +18 -0
  23. package/dist/network/fetcher.d.ts +56 -0
  24. package/dist/network/get-real-url.d.ts +2 -0
  25. package/dist/network/getRealURL.d.ts +2 -0
  26. package/dist/network/image.d.ts +59 -0
  27. package/dist/network/index.d.ts +4 -0
  28. package/dist/network/to.d.ts +9 -0
  29. package/dist/number/index.d.ts +1 -0
  30. package/dist/number/random-int.d.ts +7 -0
  31. package/dist/number/randomInt.d.ts +7 -0
  32. package/dist/object/index.d.ts +3 -0
  33. package/dist/object/map-keys.d.ts +17 -0
  34. package/dist/object/map-values.d.ts +21 -0
  35. package/dist/object/mapKeys.d.ts +17 -0
  36. package/dist/object/mapValues.d.ts +21 -0
  37. package/dist/object/merge-objects.d.ts +12 -0
  38. package/dist/object/mergeObjects.d.ts +12 -0
  39. package/dist/string/case.d.ts +32 -0
  40. package/dist/string/compact.d.ts +22 -0
  41. package/dist/string/index.d.ts +2 -0
  42. package/dist/time/debounce.d.ts +20 -0
  43. package/dist/time/index.d.ts +3 -0
  44. package/dist/time/sleep.d.ts +7 -0
  45. package/dist/time/throttle.d.ts +20 -0
  46. package/docs/assets/navigation.js +1 -1
  47. package/docs/assets/search.js +1 -1
  48. package/docs/functions/camelToSnake.html +1 -1
  49. package/docs/functions/capitalize.html +1 -1
  50. package/docs/functions/compactStr.html +1 -1
  51. package/docs/functions/debounce.html +1 -1
  52. package/docs/functions/decapitalize.html +1 -1
  53. package/docs/functions/fetcher.html +1 -1
  54. package/docs/functions/getRealURL.html +1 -1
  55. package/docs/functions/imageUrlToBase64.html +1 -1
  56. package/docs/functions/isFalsy.html +1 -1
  57. package/docs/functions/isNil.html +1 -1
  58. package/docs/functions/isObject.html +1 -1
  59. package/docs/functions/isPrimitive.html +1 -1
  60. package/docs/functions/{isTruthy.html → log.html} +6 -4
  61. package/docs/functions/loopUntil.html +1 -1
  62. package/docs/functions/mapKeys.html +1 -1
  63. package/docs/functions/mapValues.html +1 -1
  64. package/docs/functions/mergeObjects.html +1 -1
  65. package/docs/functions/randomInt.html +1 -1
  66. package/docs/functions/sleep.html +1 -1
  67. package/docs/functions/snakeToCamel.html +1 -1
  68. package/docs/functions/throttle.html +1 -1
  69. package/docs/functions/to.html +1 -1
  70. package/docs/functions/withCache.html +3 -3
  71. package/docs/{functions/timeLog.html → interfaces/LogOptions.html} +11 -4
  72. package/docs/modules.html +1 -1
  73. package/docs/types/BunFetchOptions.html +2 -2
  74. package/docs/types/CamelToSnake.html +1 -1
  75. package/docs/types/Capitalize.html +1 -1
  76. package/docs/types/Decapitalize.html +1 -1
  77. package/docs/types/DeepMapKeys.html +1 -1
  78. package/docs/types/DeepMapValues.html +1 -1
  79. package/docs/types/Falsy.html +1 -1
  80. package/docs/types/ImageCompressionOptions.html +4 -4
  81. package/docs/types/Primitive.html +1 -1
  82. package/docs/types/RequestInit.html +1 -1
  83. package/docs/types/SetTtl.html +1 -1
  84. package/docs/types/SnakeToCamel.html +1 -1
  85. package/package.json +1 -1
  86. package/src/dom/index.ts +1 -1
  87. package/src/dom/log.ts +62 -0
  88. package/src/function/index.ts +1 -1
  89. package/src/hoc/index.ts +1 -1
  90. package/src/is/index.ts +4 -5
  91. package/src/network/fetcher.ts +1 -0
  92. package/src/network/index.ts +4 -4
  93. package/src/number/index.ts +1 -1
  94. package/src/object/index.ts +3 -3
  95. package/src/string/index.ts +2 -12
  96. package/src/time/index.ts +3 -3
  97. package/src/lru-cache.ts +0 -50
  98. /package/src/function/{loopUntil.ts → loop-until.ts} +0 -0
  99. /package/src/hoc/{withCache.ts → with-cache.ts} +0 -0
  100. /package/src/is/{isFalsy.ts → is-falsy.ts} +0 -0
  101. /package/src/is/{isNil.ts → is-nil.ts} +0 -0
  102. /package/src/is/{isObject.ts → is-object.ts} +0 -0
  103. /package/src/is/{isPrimitive.ts → is-primitive.ts} +0 -0
  104. /package/src/network/{getRealURL.ts → get-real-url.ts} +0 -0
  105. /package/src/number/{randomInt.ts → random-int.ts} +0 -0
  106. /package/src/object/{mapKeys.ts → map-keys.ts} +0 -0
  107. /package/src/object/{mapValues.ts → map-values.ts} +0 -0
  108. /package/src/object/{mergeObjects.ts → merge-objects.ts} +0 -0
@@ -1,4 +1,4 @@
1
- export { type BunFetchOptions, fetcher, type RequestInit } from "./fetcher";
2
- export { getRealURL } from "./getRealURL";
3
- export { type ImageCompressionOptions, imageUrlToBase64 } from "./image";
4
- export { to } from "./to";
1
+ export * from "./fetcher";
2
+ export * from "./get-real-url";
3
+ export * from "./image";
4
+ export * from "./to";
@@ -1 +1 @@
1
- export { randomInt } from "./randomInt";
1
+ export * from "./random-int";
@@ -1,3 +1,3 @@
1
- export { type DeepMapKeys, mapKeys } from "./mapKeys";
2
- export { type DeepMapValues, mapValues } from "./mapValues";
3
- export { mergeObjects } from "./mergeObjects";
1
+ export * from "./map-keys";
2
+ export * from "./map-values";
3
+ export * from "./merge-objects";
@@ -1,12 +1,2 @@
1
- export {
2
- type CamelToSnake,
3
- type Capitalize,
4
- camelToSnake,
5
- capitalize,
6
- type Decapitalize,
7
- decapitalize,
8
- type SnakeToCamel,
9
- snakeToCamel,
10
- } from "./case";
11
-
12
- export { compactStr } from "./compact";
1
+ export * from "./case";
2
+ export * from "./compact";
package/src/time/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { debounce } from "./debounce";
2
- export { sleep } from "./sleep";
3
- export { throttle } from "./throttle";
1
+ export * from "./debounce";
2
+ export * from "./sleep";
3
+ export * from "./throttle";
package/src/lru-cache.ts DELETED
@@ -1,50 +0,0 @@
1
- /**
2
- * 简易 LRU 缓存
3
- * @example
4
- * const cache = new LRUCache<string, number>(2);
5
- * cache.set("a", 1);
6
- * cache.set("b", 2);
7
- * cache.set("c", 3); // 缓存已满,a 被淘汰
8
- * cache.get("a"); // undefined
9
- */
10
- class LRUCache<K, V> {
11
- private cache: Map<K, V>;
12
- private maxSize: number;
13
-
14
- constructor(maxSize = 10) {
15
- this.cache = new Map();
16
- this.maxSize = maxSize;
17
- }
18
-
19
- get(key: K): V | undefined {
20
- if (!this.cache.has(key)) {
21
- return undefined;
22
- }
23
- const value = this.cache.get(key)!;
24
- // 重置缓存顺序
25
- this.cache.delete(key);
26
- this.cache.set(key, value);
27
- return value;
28
- }
29
-
30
- set(key: K, value: V) {
31
- // 刷新缓存
32
- if (this.cache.has(key)) {
33
- this.cache.delete(key);
34
- }
35
- // 删除最旧的缓存
36
- else if (this.cache.size >= this.maxSize) {
37
- const oldestKey = [...this.cache.keys()][0];
38
- if (oldestKey) {
39
- this.cache.delete(oldestKey);
40
- }
41
- }
42
- this.cache.set(key, value);
43
- }
44
-
45
- has(key: K) {
46
- return this.cache.has(key);
47
- }
48
- }
49
-
50
- export default LRUCache;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes