@nickyzj2023/utils 1.0.55 → 1.0.57
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/README.md +1 -3
- package/dist/index.d.ts +446 -9
- package/dist/index.js +2 -3
- package/package.json +15 -4
- package/AGENTS.md +0 -167
- package/biome.json +0 -37
- package/dist/dom/index.d.ts +0 -1
- package/dist/dom/log.d.ts +0 -28
- package/dist/dom/timeLog.d.ts +0 -8
- package/dist/function/index.d.ts +0 -1
- package/dist/function/loop-until.d.ts +0 -36
- package/dist/function/loopUntil.d.ts +0 -22
- package/dist/hoc/index.d.ts +0 -1
- package/dist/hoc/with-cache.d.ts +0 -42
- package/dist/hoc/withCache.d.ts +0 -42
- package/dist/is/index.d.ts +0 -4
- package/dist/is/is-falsy.d.ts +0 -9
- package/dist/is/is-nil.d.ts +0 -9
- package/dist/is/is-object.d.ts +0 -8
- package/dist/is/is-primitive.d.ts +0 -9
- package/dist/is/isFalsy.d.ts +0 -9
- package/dist/is/isNil.d.ts +0 -9
- package/dist/is/isObject.d.ts +0 -8
- package/dist/is/isPrimitive.d.ts +0 -9
- package/dist/is/isTruthy.d.ts +0 -8
- package/dist/lru-cache.d.ts +0 -18
- package/dist/network/fetcher.d.ts +0 -56
- package/dist/network/get-real-url.d.ts +0 -2
- package/dist/network/getRealURL.d.ts +0 -2
- package/dist/network/image.d.ts +0 -59
- package/dist/network/index.d.ts +0 -4
- package/dist/network/to.d.ts +0 -9
- package/dist/number/index.d.ts +0 -1
- package/dist/number/random-int.d.ts +0 -7
- package/dist/number/randomInt.d.ts +0 -7
- package/dist/object/index.d.ts +0 -3
- package/dist/object/map-keys.d.ts +0 -17
- package/dist/object/map-values.d.ts +0 -21
- package/dist/object/mapKeys.d.ts +0 -17
- package/dist/object/mapValues.d.ts +0 -21
- package/dist/object/merge-objects.d.ts +0 -12
- package/dist/object/mergeObjects.d.ts +0 -12
- package/dist/string/case.d.ts +0 -32
- package/dist/string/compact.d.ts +0 -22
- package/dist/string/index.d.ts +0 -2
- package/dist/time/debounce.d.ts +0 -20
- package/dist/time/index.d.ts +0 -3
- package/dist/time/sleep.d.ts +0 -7
- package/dist/time/throttle.d.ts +0 -20
- package/docs/.nojekyll +0 -1
- package/docs/assets/hierarchy.js +0 -1
- package/docs/assets/highlight.css +0 -92
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/material-style.css +0 -262
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1633
- package/docs/functions/camelToSnake.html +0 -178
- package/docs/functions/capitalize.html +0 -178
- package/docs/functions/compactStr.html +0 -182
- package/docs/functions/debounce.html +0 -187
- package/docs/functions/decapitalize.html +0 -178
- package/docs/functions/fetcher.html +0 -189
- package/docs/functions/getRealURL.html +0 -175
- package/docs/functions/imageUrlToBase64.html +0 -191
- package/docs/functions/isFalsy.html +0 -178
- package/docs/functions/isNil.html +0 -178
- package/docs/functions/isObject.html +0 -178
- package/docs/functions/isPrimitive.html +0 -178
- package/docs/functions/log.html +0 -180
- package/docs/functions/loopUntil.html +0 -186
- package/docs/functions/mapKeys.html +0 -180
- package/docs/functions/mapValues.html +0 -182
- package/docs/functions/mergeObjects.html +0 -184
- package/docs/functions/randomInt.html +0 -178
- package/docs/functions/sleep.html +0 -179
- package/docs/functions/snakeToCamel.html +0 -178
- package/docs/functions/throttle.html +0 -187
- package/docs/functions/to.html +0 -180
- package/docs/functions/withCache.html +0 -185
- package/docs/hierarchy.html +0 -174
- package/docs/index.html +0 -184
- package/docs/interfaces/LogOptions.html +0 -185
- package/docs/modules.html +0 -174
- package/docs/types/BunFetchOptions.html +0 -176
- package/docs/types/CamelToSnake.html +0 -174
- package/docs/types/Capitalize.html +0 -174
- package/docs/types/Decapitalize.html +0 -174
- package/docs/types/DeepMapKeys.html +0 -174
- package/docs/types/DeepMapValues.html +0 -174
- package/docs/types/Falsy.html +0 -174
- package/docs/types/ImageCompressionOptions.html +0 -188
- package/docs/types/Primitive.html +0 -174
- package/docs/types/RequestInit.html +0 -174
- package/docs/types/SetTtl.html +0 -174
- package/docs/types/SnakeToCamel.html +0 -174
- package/src/dom/index.ts +0 -1
- package/src/dom/log.ts +0 -72
- package/src/function/index.ts +0 -1
- package/src/function/loop-until.ts +0 -58
- package/src/hoc/index.ts +0 -1
- package/src/hoc/with-cache.ts +0 -117
- package/src/index.ts +0 -9
- package/src/is/index.ts +0 -4
- package/src/is/is-falsy.ts +0 -12
- package/src/is/is-nil.ts +0 -11
- package/src/is/is-object.ts +0 -10
- package/src/is/is-primitive.ts +0 -23
- package/src/network/fetcher.ts +0 -124
- package/src/network/get-real-url.ts +0 -18
- package/src/network/image.ts +0 -202
- package/src/network/index.ts +0 -4
- package/src/network/to.ts +0 -17
- package/src/number/index.ts +0 -1
- package/src/number/random-int.ts +0 -9
- package/src/object/index.ts +0 -3
- package/src/object/map-keys.ts +0 -50
- package/src/object/map-values.ts +0 -77
- package/src/object/merge-objects.ts +0 -50
- package/src/string/case.ts +0 -71
- package/src/string/compact.ts +0 -56
- package/src/string/index.ts +0 -2
- package/src/time/debounce.ts +0 -34
- package/src/time/index.ts +0 -3
- package/src/time/sleep.ts +0 -11
- package/src/time/throttle.ts +0 -34
- package/tsconfig.json +0 -32
package/docs/types/SetTtl.html
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>SetTtl | @nickyzj2023/utils</title><meta name="description" content="Documentation for @nickyzj2023/utils"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><style>
|
|
2
|
-
@media (prefers-color-scheme: dark) {
|
|
3
|
-
:root {
|
|
4
|
-
--md-sys-color-primary: #f6be46;
|
|
5
|
-
--md-sys-color-on-primary: #412d00;
|
|
6
|
-
--md-sys-color-primary-container: #5d4200;
|
|
7
|
-
--md-sys-color-on-primary-container: #ffdea3;
|
|
8
|
-
--md-sys-color-secondary: #d9c4a0;
|
|
9
|
-
--md-sys-color-on-secondary: #3b2f15;
|
|
10
|
-
--md-sys-color-secondary-container: #53452a;
|
|
11
|
-
--md-sys-color-on-secondary-container: #f6e0bb;
|
|
12
|
-
--md-sys-color-tertiary: #b2cfa8;
|
|
13
|
-
--md-sys-color-on-tertiary: #1e361a;
|
|
14
|
-
--md-sys-color-tertiary-container: #344d2f;
|
|
15
|
-
--md-sys-color-on-tertiary-container: #cdebc2;
|
|
16
|
-
--md-sys-color-error: #ffb4ab;
|
|
17
|
-
--md-sys-color-on-error: #690005;
|
|
18
|
-
--md-sys-color-error-container: #93000a;
|
|
19
|
-
--md-sys-color-on-error-container: #ffb4ab;
|
|
20
|
-
--md-sys-color-background: #1e1b16;
|
|
21
|
-
--md-sys-color-on-background: #e9e1d9;
|
|
22
|
-
--md-sys-color-surface: #1e1b16;
|
|
23
|
-
--md-sys-color-on-surface: #e9e1d9;
|
|
24
|
-
--md-sys-color-surface-variant: #4e4639;
|
|
25
|
-
--md-sys-color-on-surface-variant: #d1c5b4;
|
|
26
|
-
--md-sys-color-outline: #9a8f80;
|
|
27
|
-
--md-sys-color-outline-variant: #4e4639;
|
|
28
|
-
--md-sys-color-shadow: #000000;
|
|
29
|
-
--md-sys-color-scrim: #000000;
|
|
30
|
-
--md-sys-color-inverse-surface: #e9e1d9;
|
|
31
|
-
--md-sys-color-inverse-on-surface: #34302a;
|
|
32
|
-
--md-sys-color-inverse-primary: #7a5900;
|
|
33
|
-
--md-sys-color-surface-dim: #16130e;
|
|
34
|
-
--md-sys-color-surface-bright: #3d3933;
|
|
35
|
-
--md-sys-color-surface-container-lowest: #110e09;
|
|
36
|
-
--md-sys-color-surface-container-low: #1e1b16;
|
|
37
|
-
--md-sys-color-surface-container: #221f1a;
|
|
38
|
-
--md-sys-color-surface-container-high: #2d2924;
|
|
39
|
-
--md-sys-color-surface-container-highest: #38342e
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
:root[data-theme="dark"] {
|
|
43
|
-
--md-sys-color-primary: #f6be46;
|
|
44
|
-
--md-sys-color-on-primary: #412d00;
|
|
45
|
-
--md-sys-color-primary-container: #5d4200;
|
|
46
|
-
--md-sys-color-on-primary-container: #ffdea3;
|
|
47
|
-
--md-sys-color-secondary: #d9c4a0;
|
|
48
|
-
--md-sys-color-on-secondary: #3b2f15;
|
|
49
|
-
--md-sys-color-secondary-container: #53452a;
|
|
50
|
-
--md-sys-color-on-secondary-container: #f6e0bb;
|
|
51
|
-
--md-sys-color-tertiary: #b2cfa8;
|
|
52
|
-
--md-sys-color-on-tertiary: #1e361a;
|
|
53
|
-
--md-sys-color-tertiary-container: #344d2f;
|
|
54
|
-
--md-sys-color-on-tertiary-container: #cdebc2;
|
|
55
|
-
--md-sys-color-error: #ffb4ab;
|
|
56
|
-
--md-sys-color-on-error: #690005;
|
|
57
|
-
--md-sys-color-error-container: #93000a;
|
|
58
|
-
--md-sys-color-on-error-container: #ffb4ab;
|
|
59
|
-
--md-sys-color-background: #1e1b16;
|
|
60
|
-
--md-sys-color-on-background: #e9e1d9;
|
|
61
|
-
--md-sys-color-surface: #1e1b16;
|
|
62
|
-
--md-sys-color-on-surface: #e9e1d9;
|
|
63
|
-
--md-sys-color-surface-variant: #4e4639;
|
|
64
|
-
--md-sys-color-on-surface-variant: #d1c5b4;
|
|
65
|
-
--md-sys-color-outline: #9a8f80;
|
|
66
|
-
--md-sys-color-outline-variant: #4e4639;
|
|
67
|
-
--md-sys-color-shadow: #000000;
|
|
68
|
-
--md-sys-color-scrim: #000000;
|
|
69
|
-
--md-sys-color-inverse-surface: #e9e1d9;
|
|
70
|
-
--md-sys-color-inverse-on-surface: #34302a;
|
|
71
|
-
--md-sys-color-inverse-primary: #7a5900;
|
|
72
|
-
--md-sys-color-surface-dim: #16130e;
|
|
73
|
-
--md-sys-color-surface-bright: #3d3933;
|
|
74
|
-
--md-sys-color-surface-container-lowest: #110e09;
|
|
75
|
-
--md-sys-color-surface-container-low: #1e1b16;
|
|
76
|
-
--md-sys-color-surface-container: #221f1a;
|
|
77
|
-
--md-sys-color-surface-container-high: #2d2924;
|
|
78
|
-
--md-sys-color-surface-container-highest: #38342e
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@media (prefers-color-scheme: light) {
|
|
82
|
-
:root {
|
|
83
|
-
--md-sys-color-primary: #7a5900;
|
|
84
|
-
--md-sys-color-on-primary: #ffffff;
|
|
85
|
-
--md-sys-color-primary-container: #ffdea3;
|
|
86
|
-
--md-sys-color-on-primary-container: #261900;
|
|
87
|
-
--md-sys-color-secondary: #6c5c3f;
|
|
88
|
-
--md-sys-color-on-secondary: #ffffff;
|
|
89
|
-
--md-sys-color-secondary-container: #f6e0bb;
|
|
90
|
-
--md-sys-color-on-secondary-container: #251a04;
|
|
91
|
-
--md-sys-color-tertiary: #4b6545;
|
|
92
|
-
--md-sys-color-on-tertiary: #ffffff;
|
|
93
|
-
--md-sys-color-tertiary-container: #cdebc2;
|
|
94
|
-
--md-sys-color-on-tertiary-container: #092007;
|
|
95
|
-
--md-sys-color-error: #ba1a1a;
|
|
96
|
-
--md-sys-color-on-error: #ffffff;
|
|
97
|
-
--md-sys-color-error-container: #ffdad6;
|
|
98
|
-
--md-sys-color-on-error-container: #410002;
|
|
99
|
-
--md-sys-color-background: #fffbff;
|
|
100
|
-
--md-sys-color-on-background: #1e1b16;
|
|
101
|
-
--md-sys-color-surface: #fffbff;
|
|
102
|
-
--md-sys-color-on-surface: #1e1b16;
|
|
103
|
-
--md-sys-color-surface-variant: #ede1cf;
|
|
104
|
-
--md-sys-color-on-surface-variant: #4e4639;
|
|
105
|
-
--md-sys-color-outline: #7f7667;
|
|
106
|
-
--md-sys-color-outline-variant: #d1c5b4;
|
|
107
|
-
--md-sys-color-shadow: #000000;
|
|
108
|
-
--md-sys-color-scrim: #000000;
|
|
109
|
-
--md-sys-color-inverse-surface: #34302a;
|
|
110
|
-
--md-sys-color-inverse-on-surface: #f8efe7;
|
|
111
|
-
--md-sys-color-inverse-primary: #f6be46;
|
|
112
|
-
--md-sys-color-surface-dim: #e1d9d0;
|
|
113
|
-
--md-sys-color-surface-bright: #fff8f2;
|
|
114
|
-
--md-sys-color-surface-container-lowest: #ffffff;
|
|
115
|
-
--md-sys-color-surface-container-low: #fbf2e9;
|
|
116
|
-
--md-sys-color-surface-container: #f5ede4;
|
|
117
|
-
--md-sys-color-surface-container-high: #efe7de;
|
|
118
|
-
--md-sys-color-surface-container-highest: #e9e1d9
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
:root[data-theme="light"] {
|
|
122
|
-
--md-sys-color-primary: #7a5900;
|
|
123
|
-
--md-sys-color-on-primary: #ffffff;
|
|
124
|
-
--md-sys-color-primary-container: #ffdea3;
|
|
125
|
-
--md-sys-color-on-primary-container: #261900;
|
|
126
|
-
--md-sys-color-secondary: #6c5c3f;
|
|
127
|
-
--md-sys-color-on-secondary: #ffffff;
|
|
128
|
-
--md-sys-color-secondary-container: #f6e0bb;
|
|
129
|
-
--md-sys-color-on-secondary-container: #251a04;
|
|
130
|
-
--md-sys-color-tertiary: #4b6545;
|
|
131
|
-
--md-sys-color-on-tertiary: #ffffff;
|
|
132
|
-
--md-sys-color-tertiary-container: #cdebc2;
|
|
133
|
-
--md-sys-color-on-tertiary-container: #092007;
|
|
134
|
-
--md-sys-color-error: #ba1a1a;
|
|
135
|
-
--md-sys-color-on-error: #ffffff;
|
|
136
|
-
--md-sys-color-error-container: #ffdad6;
|
|
137
|
-
--md-sys-color-on-error-container: #410002;
|
|
138
|
-
--md-sys-color-background: #fffbff;
|
|
139
|
-
--md-sys-color-on-background: #1e1b16;
|
|
140
|
-
--md-sys-color-surface: #fffbff;
|
|
141
|
-
--md-sys-color-on-surface: #1e1b16;
|
|
142
|
-
--md-sys-color-surface-variant: #ede1cf;
|
|
143
|
-
--md-sys-color-on-surface-variant: #4e4639;
|
|
144
|
-
--md-sys-color-outline: #7f7667;
|
|
145
|
-
--md-sys-color-outline-variant: #d1c5b4;
|
|
146
|
-
--md-sys-color-shadow: #000000;
|
|
147
|
-
--md-sys-color-scrim: #000000;
|
|
148
|
-
--md-sys-color-inverse-surface: #34302a;
|
|
149
|
-
--md-sys-color-inverse-on-surface: #f8efe7;
|
|
150
|
-
--md-sys-color-inverse-primary: #f6be46;
|
|
151
|
-
--md-sys-color-surface-dim: #e1d9d0;
|
|
152
|
-
--md-sys-color-surface-bright: #fff8f2;
|
|
153
|
-
--md-sys-color-surface-container-lowest: #ffffff;
|
|
154
|
-
--md-sys-color-surface-container-low: #fbf2e9;
|
|
155
|
-
--md-sys-color-surface-container: #f5ede4;
|
|
156
|
-
--md-sys-color-surface-container-high: #efe7de;
|
|
157
|
-
--md-sys-color-surface-container-highest: #e9e1d9
|
|
158
|
-
}
|
|
159
|
-
</style><link rel="stylesheet" href="../assets/material-style.css"/></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@nickyzj2023/utils</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">SetTtl</a></li></ul><h1>Type Alias SetTtl</h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">SetTtl</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">seconds</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=></span> <span class="tsd-signature-type">void</span></div><div class="tsd-type-declaration"><h4>Type Declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures"><li class="tsd-signature" id="__type"><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">seconds</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">void</span></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">seconds</span>: <span class="tsd-signature-type">number</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/Nickyzj628/utils/blob/2bd6c7fecd12cf78823204829da4d2a1c03e10c5/src/hoc/with-cache.ts#L6">hoc/with-cache.ts:6</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@nickyzj2023/utils</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div><script>
|
|
160
|
-
try {
|
|
161
|
-
const generateLinkElement = document.querySelector(".tsd-generator a");
|
|
162
|
-
const link = document.createElement("a");
|
|
163
|
-
Object.assign(link, {
|
|
164
|
-
href: "https://github.com/dmnsgn/typedoc-material-theme",
|
|
165
|
-
target: "_blank",
|
|
166
|
-
rel: "noreferrer",
|
|
167
|
-
innerText: "typedoc-material-theme."
|
|
168
|
-
});
|
|
169
|
-
generateLinkElement.insertAdjacentElement("afterend", link);
|
|
170
|
-
generateLinkElement.insertAdjacentText("afterend", " with ");
|
|
171
|
-
} catch (error) {
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
</script></body></html>
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>SnakeToCamel | @nickyzj2023/utils</title><meta name="description" content="Documentation for @nickyzj2023/utils"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><style>
|
|
2
|
-
@media (prefers-color-scheme: dark) {
|
|
3
|
-
:root {
|
|
4
|
-
--md-sys-color-primary: #f6be46;
|
|
5
|
-
--md-sys-color-on-primary: #412d00;
|
|
6
|
-
--md-sys-color-primary-container: #5d4200;
|
|
7
|
-
--md-sys-color-on-primary-container: #ffdea3;
|
|
8
|
-
--md-sys-color-secondary: #d9c4a0;
|
|
9
|
-
--md-sys-color-on-secondary: #3b2f15;
|
|
10
|
-
--md-sys-color-secondary-container: #53452a;
|
|
11
|
-
--md-sys-color-on-secondary-container: #f6e0bb;
|
|
12
|
-
--md-sys-color-tertiary: #b2cfa8;
|
|
13
|
-
--md-sys-color-on-tertiary: #1e361a;
|
|
14
|
-
--md-sys-color-tertiary-container: #344d2f;
|
|
15
|
-
--md-sys-color-on-tertiary-container: #cdebc2;
|
|
16
|
-
--md-sys-color-error: #ffb4ab;
|
|
17
|
-
--md-sys-color-on-error: #690005;
|
|
18
|
-
--md-sys-color-error-container: #93000a;
|
|
19
|
-
--md-sys-color-on-error-container: #ffb4ab;
|
|
20
|
-
--md-sys-color-background: #1e1b16;
|
|
21
|
-
--md-sys-color-on-background: #e9e1d9;
|
|
22
|
-
--md-sys-color-surface: #1e1b16;
|
|
23
|
-
--md-sys-color-on-surface: #e9e1d9;
|
|
24
|
-
--md-sys-color-surface-variant: #4e4639;
|
|
25
|
-
--md-sys-color-on-surface-variant: #d1c5b4;
|
|
26
|
-
--md-sys-color-outline: #9a8f80;
|
|
27
|
-
--md-sys-color-outline-variant: #4e4639;
|
|
28
|
-
--md-sys-color-shadow: #000000;
|
|
29
|
-
--md-sys-color-scrim: #000000;
|
|
30
|
-
--md-sys-color-inverse-surface: #e9e1d9;
|
|
31
|
-
--md-sys-color-inverse-on-surface: #34302a;
|
|
32
|
-
--md-sys-color-inverse-primary: #7a5900;
|
|
33
|
-
--md-sys-color-surface-dim: #16130e;
|
|
34
|
-
--md-sys-color-surface-bright: #3d3933;
|
|
35
|
-
--md-sys-color-surface-container-lowest: #110e09;
|
|
36
|
-
--md-sys-color-surface-container-low: #1e1b16;
|
|
37
|
-
--md-sys-color-surface-container: #221f1a;
|
|
38
|
-
--md-sys-color-surface-container-high: #2d2924;
|
|
39
|
-
--md-sys-color-surface-container-highest: #38342e
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
:root[data-theme="dark"] {
|
|
43
|
-
--md-sys-color-primary: #f6be46;
|
|
44
|
-
--md-sys-color-on-primary: #412d00;
|
|
45
|
-
--md-sys-color-primary-container: #5d4200;
|
|
46
|
-
--md-sys-color-on-primary-container: #ffdea3;
|
|
47
|
-
--md-sys-color-secondary: #d9c4a0;
|
|
48
|
-
--md-sys-color-on-secondary: #3b2f15;
|
|
49
|
-
--md-sys-color-secondary-container: #53452a;
|
|
50
|
-
--md-sys-color-on-secondary-container: #f6e0bb;
|
|
51
|
-
--md-sys-color-tertiary: #b2cfa8;
|
|
52
|
-
--md-sys-color-on-tertiary: #1e361a;
|
|
53
|
-
--md-sys-color-tertiary-container: #344d2f;
|
|
54
|
-
--md-sys-color-on-tertiary-container: #cdebc2;
|
|
55
|
-
--md-sys-color-error: #ffb4ab;
|
|
56
|
-
--md-sys-color-on-error: #690005;
|
|
57
|
-
--md-sys-color-error-container: #93000a;
|
|
58
|
-
--md-sys-color-on-error-container: #ffb4ab;
|
|
59
|
-
--md-sys-color-background: #1e1b16;
|
|
60
|
-
--md-sys-color-on-background: #e9e1d9;
|
|
61
|
-
--md-sys-color-surface: #1e1b16;
|
|
62
|
-
--md-sys-color-on-surface: #e9e1d9;
|
|
63
|
-
--md-sys-color-surface-variant: #4e4639;
|
|
64
|
-
--md-sys-color-on-surface-variant: #d1c5b4;
|
|
65
|
-
--md-sys-color-outline: #9a8f80;
|
|
66
|
-
--md-sys-color-outline-variant: #4e4639;
|
|
67
|
-
--md-sys-color-shadow: #000000;
|
|
68
|
-
--md-sys-color-scrim: #000000;
|
|
69
|
-
--md-sys-color-inverse-surface: #e9e1d9;
|
|
70
|
-
--md-sys-color-inverse-on-surface: #34302a;
|
|
71
|
-
--md-sys-color-inverse-primary: #7a5900;
|
|
72
|
-
--md-sys-color-surface-dim: #16130e;
|
|
73
|
-
--md-sys-color-surface-bright: #3d3933;
|
|
74
|
-
--md-sys-color-surface-container-lowest: #110e09;
|
|
75
|
-
--md-sys-color-surface-container-low: #1e1b16;
|
|
76
|
-
--md-sys-color-surface-container: #221f1a;
|
|
77
|
-
--md-sys-color-surface-container-high: #2d2924;
|
|
78
|
-
--md-sys-color-surface-container-highest: #38342e
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@media (prefers-color-scheme: light) {
|
|
82
|
-
:root {
|
|
83
|
-
--md-sys-color-primary: #7a5900;
|
|
84
|
-
--md-sys-color-on-primary: #ffffff;
|
|
85
|
-
--md-sys-color-primary-container: #ffdea3;
|
|
86
|
-
--md-sys-color-on-primary-container: #261900;
|
|
87
|
-
--md-sys-color-secondary: #6c5c3f;
|
|
88
|
-
--md-sys-color-on-secondary: #ffffff;
|
|
89
|
-
--md-sys-color-secondary-container: #f6e0bb;
|
|
90
|
-
--md-sys-color-on-secondary-container: #251a04;
|
|
91
|
-
--md-sys-color-tertiary: #4b6545;
|
|
92
|
-
--md-sys-color-on-tertiary: #ffffff;
|
|
93
|
-
--md-sys-color-tertiary-container: #cdebc2;
|
|
94
|
-
--md-sys-color-on-tertiary-container: #092007;
|
|
95
|
-
--md-sys-color-error: #ba1a1a;
|
|
96
|
-
--md-sys-color-on-error: #ffffff;
|
|
97
|
-
--md-sys-color-error-container: #ffdad6;
|
|
98
|
-
--md-sys-color-on-error-container: #410002;
|
|
99
|
-
--md-sys-color-background: #fffbff;
|
|
100
|
-
--md-sys-color-on-background: #1e1b16;
|
|
101
|
-
--md-sys-color-surface: #fffbff;
|
|
102
|
-
--md-sys-color-on-surface: #1e1b16;
|
|
103
|
-
--md-sys-color-surface-variant: #ede1cf;
|
|
104
|
-
--md-sys-color-on-surface-variant: #4e4639;
|
|
105
|
-
--md-sys-color-outline: #7f7667;
|
|
106
|
-
--md-sys-color-outline-variant: #d1c5b4;
|
|
107
|
-
--md-sys-color-shadow: #000000;
|
|
108
|
-
--md-sys-color-scrim: #000000;
|
|
109
|
-
--md-sys-color-inverse-surface: #34302a;
|
|
110
|
-
--md-sys-color-inverse-on-surface: #f8efe7;
|
|
111
|
-
--md-sys-color-inverse-primary: #f6be46;
|
|
112
|
-
--md-sys-color-surface-dim: #e1d9d0;
|
|
113
|
-
--md-sys-color-surface-bright: #fff8f2;
|
|
114
|
-
--md-sys-color-surface-container-lowest: #ffffff;
|
|
115
|
-
--md-sys-color-surface-container-low: #fbf2e9;
|
|
116
|
-
--md-sys-color-surface-container: #f5ede4;
|
|
117
|
-
--md-sys-color-surface-container-high: #efe7de;
|
|
118
|
-
--md-sys-color-surface-container-highest: #e9e1d9
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
:root[data-theme="light"] {
|
|
122
|
-
--md-sys-color-primary: #7a5900;
|
|
123
|
-
--md-sys-color-on-primary: #ffffff;
|
|
124
|
-
--md-sys-color-primary-container: #ffdea3;
|
|
125
|
-
--md-sys-color-on-primary-container: #261900;
|
|
126
|
-
--md-sys-color-secondary: #6c5c3f;
|
|
127
|
-
--md-sys-color-on-secondary: #ffffff;
|
|
128
|
-
--md-sys-color-secondary-container: #f6e0bb;
|
|
129
|
-
--md-sys-color-on-secondary-container: #251a04;
|
|
130
|
-
--md-sys-color-tertiary: #4b6545;
|
|
131
|
-
--md-sys-color-on-tertiary: #ffffff;
|
|
132
|
-
--md-sys-color-tertiary-container: #cdebc2;
|
|
133
|
-
--md-sys-color-on-tertiary-container: #092007;
|
|
134
|
-
--md-sys-color-error: #ba1a1a;
|
|
135
|
-
--md-sys-color-on-error: #ffffff;
|
|
136
|
-
--md-sys-color-error-container: #ffdad6;
|
|
137
|
-
--md-sys-color-on-error-container: #410002;
|
|
138
|
-
--md-sys-color-background: #fffbff;
|
|
139
|
-
--md-sys-color-on-background: #1e1b16;
|
|
140
|
-
--md-sys-color-surface: #fffbff;
|
|
141
|
-
--md-sys-color-on-surface: #1e1b16;
|
|
142
|
-
--md-sys-color-surface-variant: #ede1cf;
|
|
143
|
-
--md-sys-color-on-surface-variant: #4e4639;
|
|
144
|
-
--md-sys-color-outline: #7f7667;
|
|
145
|
-
--md-sys-color-outline-variant: #d1c5b4;
|
|
146
|
-
--md-sys-color-shadow: #000000;
|
|
147
|
-
--md-sys-color-scrim: #000000;
|
|
148
|
-
--md-sys-color-inverse-surface: #34302a;
|
|
149
|
-
--md-sys-color-inverse-on-surface: #f8efe7;
|
|
150
|
-
--md-sys-color-inverse-primary: #f6be46;
|
|
151
|
-
--md-sys-color-surface-dim: #e1d9d0;
|
|
152
|
-
--md-sys-color-surface-bright: #fff8f2;
|
|
153
|
-
--md-sys-color-surface-container-lowest: #ffffff;
|
|
154
|
-
--md-sys-color-surface-container-low: #fbf2e9;
|
|
155
|
-
--md-sys-color-surface-container: #f5ede4;
|
|
156
|
-
--md-sys-color-surface-container-high: #efe7de;
|
|
157
|
-
--md-sys-color-surface-container-highest: #e9e1d9
|
|
158
|
-
}
|
|
159
|
-
</style><link rel="stylesheet" href="../assets/material-style.css"/></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@nickyzj2023/utils</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">SnakeToCamel</a></li></ul><h1>Type Alias SnakeToCamel<S></h1></div><div class="tsd-signature"><span class="tsd-kind-type-alias">SnakeToCamel</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#s">S</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-symbol">`</span><span class="tsd-signature-symbol">${</span><span class="tsd-signature-keyword">infer</span> <span class="tsd-kind-type-parameter">Before</span><span class="tsd-signature-symbol">}</span><span class="tsd-signature-type">_</span><span class="tsd-signature-symbol">${</span><span class="tsd-signature-keyword">infer</span> <span class="tsd-kind-type-parameter">After</span><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">`</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type tsd-kind-type-parameter">After</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-symbol">`</span><span class="tsd-signature-symbol">${</span><span class="tsd-signature-keyword">infer</span> <span class="tsd-kind-type-parameter">First</span><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">${</span><span class="tsd-signature-keyword">infer</span> <span class="tsd-kind-type-parameter">Rest</span><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">`</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">`</span><span class="tsd-signature-symbol">${</span><span class="tsd-signature-type tsd-kind-type-parameter">Before</span><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">${</span><span class="tsd-signature-type">Uppercase</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type tsd-kind-type-parameter">First</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">${</span><a href="" class="tsd-signature-type tsd-kind-type-alias">SnakeToCamel</a><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type tsd-kind-type-parameter">Rest</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">`</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type tsd-kind-type-parameter">Before</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#s">S</a></div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="s"><span class="tsd-kind-type-parameter">S</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span></span></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/Nickyzj628/utils/blob/2bd6c7fecd12cf78823204829da4d2a1c03e10c5/src/string/case.ts#L1">string/case.ts:1</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@nickyzj2023/utils</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div><script>
|
|
160
|
-
try {
|
|
161
|
-
const generateLinkElement = document.querySelector(".tsd-generator a");
|
|
162
|
-
const link = document.createElement("a");
|
|
163
|
-
Object.assign(link, {
|
|
164
|
-
href: "https://github.com/dmnsgn/typedoc-material-theme",
|
|
165
|
-
target: "_blank",
|
|
166
|
-
rel: "noreferrer",
|
|
167
|
-
innerText: "typedoc-material-theme."
|
|
168
|
-
});
|
|
169
|
-
generateLinkElement.insertAdjacentElement("afterend", link);
|
|
170
|
-
generateLinkElement.insertAdjacentText("afterend", " with ");
|
|
171
|
-
} catch (error) {
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
</script></body></html>
|
package/src/dom/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./log";
|
package/src/dom/log.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* log 配置选项
|
|
3
|
-
*/
|
|
4
|
-
export interface LogOptions {
|
|
5
|
-
/**
|
|
6
|
-
* 是否显示时间
|
|
7
|
-
* @default true
|
|
8
|
-
*/
|
|
9
|
-
time?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* 是否显示调用者文件名
|
|
12
|
-
* @default true
|
|
13
|
-
*/
|
|
14
|
-
fileName?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 带额外信息的 console.log
|
|
19
|
-
* @param message - 日志消息,支持单条消息或消息数组
|
|
20
|
-
* @param options - 配置选项
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* log("调试信息"); // "[14:30:00] [index.ts:15] 调试信息"
|
|
24
|
-
* log("调试信息", { time: false }); // "[index.ts:15] 调试信息"
|
|
25
|
-
* log("调试信息", { fileName: false }); // "[14:30:00] 调试信息"
|
|
26
|
-
* log("调试信息", { time: false, fileName: false }); // "调试信息"
|
|
27
|
-
* log(["消息1", "消息2"]); // "[14:30:00] [index.ts:15] 消息1 消息2"
|
|
28
|
-
*/
|
|
29
|
-
export const log = (message: any | any[], options?: LogOptions) => {
|
|
30
|
-
const { time = true, fileName = true } = options ?? {};
|
|
31
|
-
|
|
32
|
-
const parts: any[] = [];
|
|
33
|
-
|
|
34
|
-
// 添加时间前缀
|
|
35
|
-
if (time) {
|
|
36
|
-
parts.push(`[${new Date().toLocaleTimeString()}]`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// 添加调用者文件名前缀
|
|
40
|
-
if (fileName) {
|
|
41
|
-
/**
|
|
42
|
-
* Error
|
|
43
|
-
* at...
|
|
44
|
-
* at E:\Projects\utils\src\network\fetcher.ts:126
|
|
45
|
-
* at...
|
|
46
|
-
* at ...
|
|
47
|
-
*/
|
|
48
|
-
const { stack } = new Error();
|
|
49
|
-
|
|
50
|
-
// at E:\Projects\utils\src\network\fetcher.ts:126
|
|
51
|
-
const callerLine = stack?.split("\n")[2]?.trim();
|
|
52
|
-
|
|
53
|
-
// [原文, E:\Projects\utils\src\network\fetcher.ts, 126]
|
|
54
|
-
const match = callerLine?.match(/at\s+(.*):(\d+)/);
|
|
55
|
-
|
|
56
|
-
if (match?.[1]) {
|
|
57
|
-
// fetcher.ts
|
|
58
|
-
const fileName = match[1].split(/[/\\]/).pop();
|
|
59
|
-
// fetcher.ts:126
|
|
60
|
-
parts.push(`[${fileName}:${match[2]}]`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 添加调用者原始消息
|
|
65
|
-
if (Array.isArray(message)) {
|
|
66
|
-
parts.push(...message);
|
|
67
|
-
} else {
|
|
68
|
-
parts.push(message);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
console.log(...parts);
|
|
72
|
-
};
|
package/src/function/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./loop-until";
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 循环执行函数,直到符合停止条件
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* // 循环请求大语言模型,直到其不再调用工具
|
|
6
|
-
* loopUntil(
|
|
7
|
-
* async () => {
|
|
8
|
-
* const completion = await chatCompletions();
|
|
9
|
-
* completion.tool_calls?.forEach(chooseAndHandleTool)
|
|
10
|
-
* return completion;
|
|
11
|
-
* },
|
|
12
|
-
* {
|
|
13
|
-
* shouldStop: (completion) => !completion.tool_calls,
|
|
14
|
-
* },
|
|
15
|
-
* ),
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // 不传递 shouldStop,执行 3 次后正常返回最后结果
|
|
19
|
-
* loopUntil(
|
|
20
|
-
* () => {
|
|
21
|
-
* return doSomething();
|
|
22
|
-
* },
|
|
23
|
-
* {
|
|
24
|
-
* maxRetries: 3,
|
|
25
|
-
* },
|
|
26
|
-
* ),
|
|
27
|
-
*/
|
|
28
|
-
export const loopUntil = async <T>(
|
|
29
|
-
fn: (count: number) => T | Promise<T>,
|
|
30
|
-
options?: {
|
|
31
|
-
/**
|
|
32
|
-
* 最大循环次数
|
|
33
|
-
* @default 5
|
|
34
|
-
*/
|
|
35
|
-
maxRetries?: number;
|
|
36
|
-
/** 停止循环条件。如果未传递,则执行 maxRetries 次后退出并返回最后结果 */
|
|
37
|
-
shouldStop?: (result: T) => boolean;
|
|
38
|
-
},
|
|
39
|
-
): Promise<T> => {
|
|
40
|
-
const { maxRetries = 5, shouldStop } = options ?? {};
|
|
41
|
-
|
|
42
|
-
let lastResult: T | undefined;
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < maxRetries; i++) {
|
|
45
|
-
lastResult = await fn(i);
|
|
46
|
-
if (shouldStop?.(lastResult) === true) {
|
|
47
|
-
return lastResult;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// 循环结束时,如果未传递 shouldStop,则正常退出并返回最终结果
|
|
52
|
-
if (!shouldStop) {
|
|
53
|
-
return lastResult as T;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// 否则抛出异常
|
|
57
|
-
throw new Error(`超过了最大循环次数(${maxRetries})且未满足停止执行条件`);
|
|
58
|
-
};
|
package/src/hoc/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./with-cache";
|
package/src/hoc/with-cache.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
type CacheEntry = {
|
|
2
|
-
value: any;
|
|
3
|
-
expiresAt: number; // 时间戳(毫秒)
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export type SetTtl = (seconds: number) => void;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 创建一个带缓存的高阶函数
|
|
10
|
-
*
|
|
11
|
-
* @template Args 被包装函数的参数类型数组
|
|
12
|
-
* @template Result 被包装函数的返回类型
|
|
13
|
-
*
|
|
14
|
-
* @param fn 需要被缓存的函数,参数里附带的 setTtl 方法用于根据具体情况改写过期时间
|
|
15
|
-
* @param ttlSeconds 以秒为单位的过期时间,-1 表示永不过期,默认 -1,会被回调函数里的 setTtl() 覆盖
|
|
16
|
-
*
|
|
17
|
-
* @returns 返回包装后的函数,以及缓存相关的额外方法
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // 异步函数示例
|
|
21
|
-
* const fetchData = withCache(async function (url: string) {
|
|
22
|
-
* const data = await fetch(url).then((res) => res.json());
|
|
23
|
-
* this.setTtl(data.expiresIn); // 根据实际情况调整过期时间
|
|
24
|
-
* return data;
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* await fetchData(urlA);
|
|
28
|
-
* await fetchData(urlA); // 使用缓存结果
|
|
29
|
-
* await fetchData(urlB);
|
|
30
|
-
* await fetchData(urlB); // 使用缓存结果
|
|
31
|
-
*
|
|
32
|
-
* fetchData.clear(); // 清除缓存
|
|
33
|
-
* await fetchData(urlA); // 重新请求
|
|
34
|
-
* await fetchData(urlB); // 重新请求
|
|
35
|
-
*
|
|
36
|
-
* // 缓存过期前
|
|
37
|
-
* await sleep();
|
|
38
|
-
* fetchData.updateTtl(180); // 更新 ttl 并为所有未过期的缓存续期
|
|
39
|
-
* await fetchData(urlA); // 使用缓存结果
|
|
40
|
-
* await fetchData(urlB); // 使用缓存结果
|
|
41
|
-
*/
|
|
42
|
-
export const withCache = <Args extends any[], Result>(
|
|
43
|
-
fn: (this: { setTtl: SetTtl }, ...args: Args) => Result,
|
|
44
|
-
ttlSeconds = -1,
|
|
45
|
-
) => {
|
|
46
|
-
const cache = new Map<string, CacheEntry>();
|
|
47
|
-
|
|
48
|
-
const wrapped = (...args: Args): Result => {
|
|
49
|
-
const key = JSON.stringify(args);
|
|
50
|
-
const now = Date.now();
|
|
51
|
-
const entry = cache.get(key);
|
|
52
|
-
|
|
53
|
-
// 命中缓存且未过期
|
|
54
|
-
if (entry && now < entry.expiresAt) {
|
|
55
|
-
return entry.value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let expiresAt = ttlSeconds === -1 ? Infinity : now + ttlSeconds * 1000;
|
|
59
|
-
|
|
60
|
-
// 创建上下文,包含 setTtl 方法
|
|
61
|
-
const thisArg = {
|
|
62
|
-
setTtl: (ttl: number) => {
|
|
63
|
-
expiresAt = now + ttl * 1000;
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const result = fn.apply(thisArg, args);
|
|
68
|
-
|
|
69
|
-
// 异步函数:缓存 Promise 的 resolved 值
|
|
70
|
-
if (result instanceof Promise) {
|
|
71
|
-
const promise = result.then((resolved) => {
|
|
72
|
-
cache.set(key, {
|
|
73
|
-
value: resolved,
|
|
74
|
-
expiresAt,
|
|
75
|
-
});
|
|
76
|
-
return resolved;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// 将 promise 先塞进去避免重复请求
|
|
80
|
-
cache.set(key, {
|
|
81
|
-
value: promise,
|
|
82
|
-
expiresAt,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
return promise as Result;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// 同步函数缓存
|
|
89
|
-
cache.set(key, {
|
|
90
|
-
value: result,
|
|
91
|
-
expiresAt,
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return result;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/** 手动清除缓存 */
|
|
98
|
-
wrapped.clear = () => cache.clear();
|
|
99
|
-
|
|
100
|
-
/** 更新 TTL,同时刷新所有未过期缓存的时间 */
|
|
101
|
-
wrapped.updateTtl = (seconds: number) => {
|
|
102
|
-
// 更新默认 TTL
|
|
103
|
-
ttlSeconds = seconds;
|
|
104
|
-
|
|
105
|
-
// 给未过期缓存续期
|
|
106
|
-
const now = Date.now();
|
|
107
|
-
const newExpiresAt = now + seconds * 1000;
|
|
108
|
-
for (const [key, entry] of cache.entries()) {
|
|
109
|
-
if (entry.expiresAt > now) {
|
|
110
|
-
entry.expiresAt = newExpiresAt;
|
|
111
|
-
cache.set(key, entry);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
return wrapped;
|
|
117
|
-
};
|
package/src/index.ts
DELETED
package/src/is/index.ts
DELETED
package/src/is/is-falsy.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type Falsy = false | 0 | -0 | 0n | "" | null | undefined;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 检测传入的值是否为**假值**(false、0、''、null、undefined、NaN等)
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* isFalsy(""); // true
|
|
8
|
-
* isFalsy(1); // false
|
|
9
|
-
*/
|
|
10
|
-
export const isFalsy = (value: any): value is Falsy => {
|
|
11
|
-
return !value;
|
|
12
|
-
};
|