@nickyzj2023/utils 1.0.16 → 1.0.18
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 +35 -35
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/is.d.ts +2 -1
- package/dist/object.d.ts +35 -0
- package/dist/string.d.ts +14 -0
- package/docs/assets/material-style.css +262 -0
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/functions/camelToSnake.html +178 -0
- package/docs/functions/fetcher.html +175 -2
- package/docs/functions/isObject.html +175 -2
- package/docs/functions/isPrimitive.html +176 -3
- package/docs/functions/mapKeys.html +180 -0
- package/docs/functions/mapValues.html +181 -0
- package/docs/functions/mergeObjects.html +175 -2
- package/docs/functions/sleep.html +175 -2
- package/docs/functions/snakeToCamel.html +178 -0
- package/docs/functions/timeLog.html +175 -2
- package/docs/functions/to.html +175 -2
- package/docs/functions/withCache.html +177 -4
- package/docs/hierarchy.html +174 -1
- package/docs/index.html +175 -2
- package/docs/modules.html +174 -1
- package/docs/types/DeepMapKeys.html +174 -0
- package/docs/types/DeepMapValues.html +174 -0
- package/docs/types/Primitive.html +174 -0
- package/docs/types/RequestInit.html +174 -1
- package/docs/types/SetTtl.html +174 -1
- package/package.json +6 -2
- package/src/dom.ts +10 -10
- package/src/hoc.ts +115 -115
- package/src/index.ts +1 -0
- package/src/is.ts +3 -1
- package/src/lru-cache.ts +50 -50
- package/src/network.ts +111 -111
- package/src/object.ts +113 -0
- package/src/string.ts +22 -0
- package/src/time.ts +11 -11
- package/tsconfig.json +32 -32
package/README.md
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
男生自用全新前端工具库
|
|
2
|
-
|
|
3
|
-
安装到你的前端项目里:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
# npm
|
|
7
|
-
npm install @nickyzj2023/utils
|
|
8
|
-
|
|
9
|
-
# yarn
|
|
10
|
-
yarn add @nickyzj2023/utils
|
|
11
|
-
|
|
12
|
-
# pnpm
|
|
13
|
-
pnpm add @nickyzj2023/utils
|
|
14
|
-
|
|
15
|
-
# bun
|
|
16
|
-
bun add @nickyzj2023/utils
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
使用方式:
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { fetcher, to } from "@nickyzj2023/utils";
|
|
23
|
-
|
|
24
|
-
const api = fetcher("https://api.example.com");
|
|
25
|
-
|
|
26
|
-
const [error, data] = await to(api.get<Blog>("/blogs/hello-world"));
|
|
27
|
-
if (error) {
|
|
28
|
-
console.error(error);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
console.log(data);
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
This project was created using `bun init` in bun v1.3.2. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
|
1
|
+
男生自用全新前端工具库
|
|
2
|
+
|
|
3
|
+
安装到你的前端项目里:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# npm
|
|
7
|
+
npm install @nickyzj2023/utils
|
|
8
|
+
|
|
9
|
+
# yarn
|
|
10
|
+
yarn add @nickyzj2023/utils
|
|
11
|
+
|
|
12
|
+
# pnpm
|
|
13
|
+
pnpm add @nickyzj2023/utils
|
|
14
|
+
|
|
15
|
+
# bun
|
|
16
|
+
bun add @nickyzj2023/utils
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
使用方式:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { fetcher, to } from "@nickyzj2023/utils";
|
|
23
|
+
|
|
24
|
+
const api = fetcher("https://api.example.com");
|
|
25
|
+
|
|
26
|
+
const [error, data] = await to(api.get<Blog>("/blogs/hello-world"));
|
|
27
|
+
if (error) {
|
|
28
|
+
console.error(error);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log(data);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This project was created using `bun init` in bun v1.3.2. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var E=(...x)=>{console.log(`${new Date().toLocaleTimeString()}`,...x)};var _=(x,z=-1)=>{let H=new Map,W=(...D)=>{let $=JSON.stringify(D),J=Date.now(),I=H.get($);if(I&&J<I.expiresAt)return I.value;let F=z===-1?1/0:J+z*1000,f={setTtl:(X)=>F=J+X*1000},Q=x.apply(f,D);if(Q instanceof Promise){let X=Q.then((B)=>{return H.set($,{value:B,expiresAt:F}),B});return H.set($,{value:X,expiresAt:F}),X}return H.set($,{value:Q,expiresAt:F}),Q};return W.clear=()=>H.clear(),W.updateTtl=(D)=>{z=D;let $=Date.now(),J=$+D*1000;for(let[I,F]of H.entries())if(F.expiresAt>$)F.expiresAt=J,H.set(I,F)},W};var M=(x)=>{return x?.constructor===Object},Y=(x)=>{return x===null||x===void 0||typeof x!=="object"&&typeof x!=="function"};var Z=(x,z)=>{let H={...x};for(let W of Object.keys(z)){let D=H[W],$=z[W];if(Y(D)&&Y($)){H[W]=$;continue}if(Array.isArray(D)&&Array.isArray($)){H[W]=D.concat($);continue}if(M(D)&&M($)){H[W]=Z(D,$);continue}H[W]=$}return H},C=(x,z)=>{if(Array.isArray(x))return x.map((H)=>C(H,z));if(M(x))return Object.keys(x).reduce((W,D)=>{let $=z(D),J=x[D];return W[$]=C(J,z),W},{});return x},G=(x,z)=>{if(Array.isArray(x))return x.map((H,W)=>{if(M(H))return G(H,z);return z(H,W)});if(M(x))return Object.keys(x).reduce((W,D)=>{let $=x[D];if(!Y($))W[D]=G($,z);else W[D]=z($,D);return W},{});return x};var R=(x="",z={})=>{let H=async(W,D={})=>{let $=x?`${x}${W}`:W,{parser:J,...I}=Z(z,D);if(M(I.body))I.body=JSON.stringify(I.body),I.headers={...I.headers,"Content-Type":"application/json"};let F=await fetch($,I);if(!F.ok)throw Error(F.statusText);return await(J?.(F)??F.json())};return{get:(W,D={})=>H(W,{...D,method:"GET"}),post:(W,D,$={})=>H(W,{...$,method:"POST",body:D}),put:(W,D,$={})=>H(W,{...$,method:"PUT",body:D}),delete:(W,D={})=>H(W,{...D,method:"DELETE"})}},K=async(x)=>{try{return[null,await x]}catch(z){return[z,void 0]}};var m=(x)=>{return x.replace(/_([a-zA-Z])/g,(z,H)=>H.toUpperCase())},O=(x)=>{return x.replace(/([A-Z])/g,(z,H)=>`_${H.toLowerCase()}`)};var h=async(x=150)=>{return new Promise((z)=>{setTimeout(z,x)})};export{_ as withCache,K as to,E as timeLog,m as snakeToCamel,h as sleep,Z as mergeObjects,G as mapValues,C as mapKeys,Y as isPrimitive,M as isObject,R as fetcher,O as camelToSnake};
|
package/dist/is.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type Primitive = number | string | boolean | symbol | bigint | undefined | null;
|
|
1
2
|
/**
|
|
2
3
|
* 检测传入的值是否为**普通对象**
|
|
3
4
|
* @returns 如果是普通对象,返回 true,否则返回 false
|
|
@@ -7,4 +8,4 @@ export declare const isObject: (value: any) => value is object;
|
|
|
7
8
|
* 检测传入的值是否为**原始值**(number、string、boolean、symbol、bigint、undefined、null)
|
|
8
9
|
* @returns 如果是原始值,返回 true,否则返回 false
|
|
9
10
|
*/
|
|
10
|
-
export declare const isPrimitive: (value: any) =>
|
|
11
|
+
export declare const isPrimitive: (value: any) => value is Primitive;
|
package/dist/object.d.ts
CHANGED
|
@@ -12,3 +12,38 @@
|
|
|
12
12
|
* @param {U} obj2 要合并的第二个对象
|
|
13
13
|
*/
|
|
14
14
|
export declare const mergeObjects: <T extends Record<string, any>, U extends Record<string, any>>(obj1: T, obj2: U) => T & U;
|
|
15
|
+
export type DeepMapKeys<T> = T extends Array<infer U> ? Array<DeepMapKeys<U>> : T extends object ? {
|
|
16
|
+
[key: string]: DeepMapKeys<T[keyof T]>;
|
|
17
|
+
} : T;
|
|
18
|
+
/**
|
|
19
|
+
* 递归处理对象里的 key
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* 无法完整推导出类型,只能做到有递归,key 全为 string,value 为同层级的所有类型的联合
|
|
23
|
+
*
|
|
24
|
+
* @template T 要转换的对象
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const obj = { a: { b: 1 } };
|
|
28
|
+
* const result = mapKeys(obj, (key) => key.toUpperCase());
|
|
29
|
+
* console.log(result); // { A: { B: 1 } }
|
|
30
|
+
*/
|
|
31
|
+
export declare const mapKeys: <T>(obj: T, getNewKey: (key: string) => string) => DeepMapKeys<T>;
|
|
32
|
+
export type DeepMapValues<T, R> = T extends Array<infer U> ? Array<DeepMapValues<U, R>> : T extends object ? {
|
|
33
|
+
[K in keyof T]: T[K] extends object ? DeepMapValues<T[K], R> : R;
|
|
34
|
+
} : R;
|
|
35
|
+
/**
|
|
36
|
+
* 递归处理对象里的 value
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* 无法完整推导出类型,所有 value 最终都会变为 any
|
|
40
|
+
*
|
|
41
|
+
* @template T 要转换的对象
|
|
42
|
+
* @template R 转换后的值类型,为 any,无法进一步推导
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const obj = { a: 1, b: { c: 2 } };
|
|
46
|
+
* const result = mapValues(obj, (value, key) => isPrimitive(value) ? value + 1 : value);
|
|
47
|
+
* console.log(result); // { a: 2, b: { c: 3 } }
|
|
48
|
+
*/
|
|
49
|
+
export declare const mapValues: <T, R = any>(obj: T, getNewValue: (value: any, key: string | number) => R) => DeepMapValues<T, R>;
|
package/dist/string.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 转换下划线命名法为驼峰命名法
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* snakeToCamel("user_name") // 'userName'
|
|
6
|
+
*/
|
|
7
|
+
export declare const snakeToCamel: (str: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* 转换驼峰命名法为下划线命名法
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* camelToSnake("shouldComponentUpdate") // 'should_component_update'
|
|
13
|
+
*/
|
|
14
|
+
export declare const camelToSnake: (str: string) => string;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap");
|
|
2
|
+
|
|
3
|
+
:root,
|
|
4
|
+
:root[data-theme="light"],
|
|
5
|
+
:root[data-theme="dark"] {
|
|
6
|
+
--font-sans: "Space Grotesk", sans-serif;
|
|
7
|
+
--font-mono: "Space Mono", monospace;
|
|
8
|
+
|
|
9
|
+
--color-background: var(--md-sys-color-surface-container);
|
|
10
|
+
--color-background-secondary: var(--md-sys-color-surface-container-high);
|
|
11
|
+
--color-background-warning: var(--md-sys-color-error-container);
|
|
12
|
+
--color-warning-text: var(--md-sys-color-on-error-container);
|
|
13
|
+
--color-icon-background: var(--md-sys-color-on-primary);
|
|
14
|
+
--color-accent: var(--md-sys-color-secondary-container);
|
|
15
|
+
--color-active-menu-item: var(--md-sys-color-surface-container-highest);
|
|
16
|
+
--color-text: var(--md-sys-color-on-surface);
|
|
17
|
+
--color-text-aside: var(--md-sys-color-on-surface-variant);
|
|
18
|
+
--color-link: var(--md-sys-color-primary);
|
|
19
|
+
|
|
20
|
+
--color-ts-project: var(--md-sys-color-secondary);
|
|
21
|
+
--color-ts-module: var(--color-ts-project);
|
|
22
|
+
--color-ts-namespace: var(--color-ts-project);
|
|
23
|
+
|
|
24
|
+
--color-ts-enum: var(--md-sys-color-tertiary);
|
|
25
|
+
--color-ts-enum-member: var(--color-ts-enum);
|
|
26
|
+
|
|
27
|
+
--color-ts-variable: var(--md-sys-color-primary);
|
|
28
|
+
--color-ts-function: var(--md-sys-color-secondary);
|
|
29
|
+
--color-ts-class: var(--md-sys-color-tertiary);
|
|
30
|
+
--color-ts-interface: var(--md-sys-color-tertiary);
|
|
31
|
+
|
|
32
|
+
--color-ts-constructor: var(--md-sys-color-inverse-primary);
|
|
33
|
+
|
|
34
|
+
--color-ts-property: var(--md-sys-color-on-background);
|
|
35
|
+
--color-ts-method: var(--color-ts-function);
|
|
36
|
+
|
|
37
|
+
--color-ts-call-signature: var(--color-ts-method);
|
|
38
|
+
--color-ts-index-signature: var(--color-ts-property); /* ? */
|
|
39
|
+
--color-ts-constructor-signature: var(--color-ts-function);
|
|
40
|
+
--color-ts-parameter: var(--md-sys-color-primary);
|
|
41
|
+
|
|
42
|
+
--color-ts-type-parameter: var(--md-sys-color-tertiary);
|
|
43
|
+
--color-ts-accessor: var(--color-ts-property);
|
|
44
|
+
--color-ts-get-signature: var(--color-ts-accessor);
|
|
45
|
+
--color-ts-set-signature: var(--color-ts-accessor);
|
|
46
|
+
--color-ts-type-alias: var(--md-sys-color-tertiary);
|
|
47
|
+
|
|
48
|
+
/* --external-icon: var(--md-sys-external-icon);
|
|
49
|
+
--color-scheme: var(--md-sys-color-scheme); */
|
|
50
|
+
|
|
51
|
+
--top-app-bar-height: 4.5rem;
|
|
52
|
+
--top-app-bar-padding-vertical: .5rem;
|
|
53
|
+
--footer-height: 3.5rem;
|
|
54
|
+
|
|
55
|
+
--safe-area-inset-top: env(safe-area-inset-top);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
body {
|
|
59
|
+
font-family: var(--font-sans);
|
|
60
|
+
}
|
|
61
|
+
code,
|
|
62
|
+
pre {
|
|
63
|
+
font-family: var(--font-mono);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
img {
|
|
67
|
+
max-width: 100%;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@supports not selector(::-webkit-scrollbar) {
|
|
71
|
+
* {
|
|
72
|
+
scrollbar-width: thin;
|
|
73
|
+
scrollbar-color: var(--color-accent) transparent;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@supports selector(::-webkit-scrollbar) {
|
|
78
|
+
*::-webkit-scrollbar {
|
|
79
|
+
width: 8px;
|
|
80
|
+
height: 8px;
|
|
81
|
+
}
|
|
82
|
+
*::-webkit-scrollbar-track {
|
|
83
|
+
background: none;
|
|
84
|
+
margin: 4px;
|
|
85
|
+
}
|
|
86
|
+
*::-webkit-scrollbar-thumb {
|
|
87
|
+
border: none;
|
|
88
|
+
}
|
|
89
|
+
*::-webkit-scrollbar-thumb:hover,
|
|
90
|
+
*::-webkit-scrollbar-thumb:active {
|
|
91
|
+
background-color: var(--md-sys-color-secondary);
|
|
92
|
+
}
|
|
93
|
+
* {
|
|
94
|
+
scrollbar-width: unset;
|
|
95
|
+
scrollbar-color: unset;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.container-main {
|
|
100
|
+
min-height: calc(100vh - var(--top-app-bar-height) - var(--footer-height));
|
|
101
|
+
}
|
|
102
|
+
.col-content {
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
position: relative;
|
|
105
|
+
box-sizing: border-box;
|
|
106
|
+
padding: 1.75rem;
|
|
107
|
+
margin-bottom: 1.75rem;
|
|
108
|
+
border-radius: 28px;
|
|
109
|
+
background-color: var(--md-sys-color-surface);
|
|
110
|
+
}
|
|
111
|
+
.page-menu {
|
|
112
|
+
height: fit-content;
|
|
113
|
+
padding: 1.25rem 1.75rem;
|
|
114
|
+
border-radius: 28px;
|
|
115
|
+
background-color: var(--md-sys-color-surface);
|
|
116
|
+
}
|
|
117
|
+
.site-menu > *,
|
|
118
|
+
.page-menu > * {
|
|
119
|
+
position: relative;
|
|
120
|
+
}
|
|
121
|
+
.title {
|
|
122
|
+
display: inline-block;
|
|
123
|
+
white-space: nowrap;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
text-overflow: ellipsis;
|
|
126
|
+
font-size: 22px;
|
|
127
|
+
}
|
|
128
|
+
.tsd-page-title {
|
|
129
|
+
word-break: break-all;
|
|
130
|
+
}
|
|
131
|
+
.tsd-page-toolbar {
|
|
132
|
+
padding: 1rem 0;
|
|
133
|
+
background-color: var(--color-background);
|
|
134
|
+
border-bottom: none;
|
|
135
|
+
}
|
|
136
|
+
.tsd-page-toolbar .tsd-toolbar-icon {
|
|
137
|
+
padding: 20px 0;
|
|
138
|
+
}
|
|
139
|
+
#tsd-search {
|
|
140
|
+
border-radius: 38px;
|
|
141
|
+
}
|
|
142
|
+
#tsd-search-input {
|
|
143
|
+
border-radius: 22px;
|
|
144
|
+
}
|
|
145
|
+
#tsd-search-input:focus-visible {
|
|
146
|
+
background-color: var(--color-accent);
|
|
147
|
+
}
|
|
148
|
+
#tsd-search-results > li {
|
|
149
|
+
background: none;
|
|
150
|
+
}
|
|
151
|
+
#tsd-toolbar-menu-trigger,
|
|
152
|
+
#tsd-search-trigger {
|
|
153
|
+
border-radius: 50%;
|
|
154
|
+
}
|
|
155
|
+
html:not(.has-menu) .col-sidebar {
|
|
156
|
+
padding-top: 0;
|
|
157
|
+
margin-right: 1rem;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.tsd-signature {
|
|
161
|
+
padding: 1rem 1.5rem;
|
|
162
|
+
border-radius: 24px;
|
|
163
|
+
background-color: var(--md-sys-color-surface-container);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.tsd-page-navigation ul {
|
|
167
|
+
padding-left: 0.44rem;
|
|
168
|
+
}
|
|
169
|
+
.tsd-navigation a,
|
|
170
|
+
.tsd-navigation summary > span,
|
|
171
|
+
.tsd-page-navigation a {
|
|
172
|
+
padding: 0.88rem;
|
|
173
|
+
border-radius: 24px;
|
|
174
|
+
}
|
|
175
|
+
.tsd-navigation a:hover,
|
|
176
|
+
.tsd-page-navigation a:hover {
|
|
177
|
+
text-decoration: none;
|
|
178
|
+
background-color: var(--md-sys-color-surface-container-high);
|
|
179
|
+
}
|
|
180
|
+
.page-menu .tsd-accordion-summary {
|
|
181
|
+
margin-bottom: 0.5rem;
|
|
182
|
+
}
|
|
183
|
+
.page-menu .tsd-accordion-summary svg {
|
|
184
|
+
position: absolute;
|
|
185
|
+
right: 0;
|
|
186
|
+
}
|
|
187
|
+
.site-menu .tsd-navigation .tsd-accordion-summary {
|
|
188
|
+
display: flex;
|
|
189
|
+
flex-direction: row-reverse;
|
|
190
|
+
width: 100%;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.tsd-small-nested-navigation {
|
|
194
|
+
margin-left: 1rem;
|
|
195
|
+
}
|
|
196
|
+
.tsd-nested-navigation {
|
|
197
|
+
margin-left: 2.5rem;
|
|
198
|
+
}
|
|
199
|
+
.tsd-nested-navigation > li > a,
|
|
200
|
+
.tsd-nested-navigation > li > span {
|
|
201
|
+
width: 100%;
|
|
202
|
+
}
|
|
203
|
+
.tsd-navigation > a,
|
|
204
|
+
.tsd-navigation .tsd-accordion-summary {
|
|
205
|
+
width: 100%;
|
|
206
|
+
}
|
|
207
|
+
.tsd-accordion .tsd-accordion-summary > svg,
|
|
208
|
+
.tsd-index-accordion .tsd-accordion-summary > svg {
|
|
209
|
+
position: absolute;
|
|
210
|
+
right: 1.5rem;
|
|
211
|
+
}
|
|
212
|
+
.tsd-accordion-summary .tsd-kind-icon ~ span {
|
|
213
|
+
margin-right: 2.5rem;
|
|
214
|
+
}
|
|
215
|
+
.tsd-accordion-summary .tsd-nested-navigation > li > a,
|
|
216
|
+
.tsd-nested-navigation > li > span {
|
|
217
|
+
width: calc(100% - 0.44rem);
|
|
218
|
+
}
|
|
219
|
+
.tsd-kind-icon ~ span {
|
|
220
|
+
white-space: nowrap;
|
|
221
|
+
overflow: hidden;
|
|
222
|
+
text-overflow: ellipsis;
|
|
223
|
+
}
|
|
224
|
+
.tsd-generator {
|
|
225
|
+
padding: 0;
|
|
226
|
+
border-top: none;
|
|
227
|
+
height: var(--footer-height);
|
|
228
|
+
line-height: var(--footer-height);
|
|
229
|
+
}
|
|
230
|
+
.tsd-generator > p {
|
|
231
|
+
padding: 0 2rem;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@media (max-width: 769px) {
|
|
235
|
+
.col-sidebar {
|
|
236
|
+
margin-right: 0;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
@media (min-width: 770px) {
|
|
240
|
+
.container-main {
|
|
241
|
+
margin: 0 auto;
|
|
242
|
+
}
|
|
243
|
+
.site-menu {
|
|
244
|
+
margin-right: 0.5rem;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
@media (min-width: 1200px) {
|
|
248
|
+
.page-menu,
|
|
249
|
+
.site-menu {
|
|
250
|
+
max-height: calc(100vh - var(--footer-height) - var(--top-app-bar-height));
|
|
251
|
+
top: var(--top-app-bar-height);
|
|
252
|
+
}
|
|
253
|
+
.site-menu {
|
|
254
|
+
margin-top: 0;
|
|
255
|
+
}
|
|
256
|
+
.page-menu {
|
|
257
|
+
margin-left: 1rem;
|
|
258
|
+
}
|
|
259
|
+
.col-sidebar {
|
|
260
|
+
margin-right: 0;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.navigationData = "
|
|
1
|
+
window.navigationData = "eJyFksFKxDAURf/lrYvVYVTMdtyIiuIUN+Iixus0TpLW5o1aZP5daidgQ9puczgHwn1PP8T4ZhJ0CdS3sr5G6ymjWnJJgrit4fOA0Pqjkq2hjLbavZJYHF+cn5wu9llceZRmh7FOD+dK9422mvUn4koAmCs84GMHz1dOc9wIyGmeq6zBBZs40L/OuUpamKJaO7kN3yBBbzunWFfO5//5sHW2DJlOAKsSTapwQGMyCdL+7uUdilN2YJN6PERUGJljELHxXYWAz23qrmI5PqeBnjqnYQDNBv1H043AFU9lvAHqlP8HpsRu3qJadWMn/cAtzFimOzxtcVNtUoUDmpKrpFeNKSToS3O5kqpM7h5gvPpy//wLbJ10Yw=="
|
package/docs/assets/search.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.searchData = "
|
|
1
|
+
window.searchData = "eJyVlktv2zAQhP/LnInY9Nu8ppegLVo0QS6CUbjyJmGjV0XaSSD4vxcUtYBCsA19s2c1n0BytNwObf1ioLIOz7o6QM2m27VczgSqfUlQ+ETUfN03n+nNQODYFlCwbw2ZCVfozVw92bKAQF7sjSEDBZzFB8T7fXGkfzB97SLq91aX2uoTBUTW6SLaD/pzJGNvKm0DHlcqbS8i3pK9s0UA8+J/OasFI5DvSyru6ttq/8yrVHg4VrnVdWUm43Iq8oFs/kRtSKvMZKikgrT59us35TYkVWbCpVSUNuFZvqelnSgDoVAG8WWYmZQfxTcEhal9h/ootQGM2kfyOxPlcTm3qUiYgqgJWZWZ9HoqxLj83NXXLk0xFpdLSg0urC7pS/0Y0iozGSqpIFvHGHWq/UXbp+t9/hTLFdeiqdoJ6OpAr1AdTtQaXVdQmF3Nr7YQeNBUHFwP9e8RyOuypMp9C4c6P/Y/d8Nj95TbunUP+6cnU4hsKmaLq81iu9uJjM19oReYwcpglBCZjBllaGRlMM4gslnMOAuNrAzGOUQ2jxnnoZGVwbiAyBYx4yI0sjIYlxDZMmZchkZWBuMKIlvFjKvQyMpgXENk65hxHRpZGYwbiGwTM25CIyuDcQuRbWPGbWhkhQPg8iCj2ZFheMaSN/fxiecnDNBY8maXCxnNkAxDNJa82WVDRnMkwyCNJW92+ZDRLMkwTGPJm11GZDRPMgzUWPJmlxMZzZQMQ8XSru8bJ2otHW58/8gyf43b2vhrvMPPobUsuU91WEJ15zM3Euv+cS/x/87924iact8893cbc6CmzOkwvYRzGq42JkFJJnWQSSQeJ5jxCrViRodVEkObepgkGAK1ZkiHdSKk4SlhzNkwp8MmiRNu7yvUlhkdtqmMcGuhJJ+S29u0Y+ongpoHBkZByfExpZ1TdHN4VlUdZkmU1o/Cuh+SmQM1Z06HeRLHkLVuNGYEFF/ZqsMiDeEnHyZASV6N25S05fQfpK1zP/gwCkryghwqbUVurCncwMMUKMlrcpS0RblphwFQkvuDA6Q1CDfT5H7eYQ6U5C/ScT76JM9n18Ma3VChK4LKdufzX6fOkTE=";
|
|
@@ -0,0 +1,178 @@
|
|
|
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>camelToSnake | @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">camelToSnake</a></li></ul><h1>Function camelToSnake</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="cameltosnake"><span class="tsd-kind-call-signature">camelToSnake</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">str</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><a href="#cameltosnake" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>转换驼峰命名法为下划线命名法</p>
|
|
160
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">str</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><div class="tsd-comment tsd-typography"><div class="tsd-tag-example"><h4 class="tsd-anchor-link" id="example">Example<a href="#example" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><pre><code class="ts"><span class="hl-1">camelToSnake</span><span class="hl-2">(</span><span class="hl-3">"shouldComponentUpdate"</span><span class="hl-2">) </span><span class="hl-0">// 'should_component_update'</span>
|
|
161
|
+
</code><button type="button">Copy</button></pre>
|
|
162
|
+
|
|
163
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/Nickyzj628/utils/blob/f408a18bf8828de9cc8d925dac8de5602462d99c/src/string.ts#L17">string.ts:17</a></li></ul></aside></div></li></ul></section></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>
|
|
164
|
+
try {
|
|
165
|
+
const generateLinkElement = document.querySelector(".tsd-generator a");
|
|
166
|
+
const link = document.createElement("a");
|
|
167
|
+
Object.assign(link, {
|
|
168
|
+
href: "https://github.com/dmnsgn/typedoc-material-theme",
|
|
169
|
+
target: "_blank",
|
|
170
|
+
rel: "noreferrer",
|
|
171
|
+
innerText: "typedoc-material-theme."
|
|
172
|
+
});
|
|
173
|
+
generateLinkElement.insertAdjacentElement("afterend", link);
|
|
174
|
+
generateLinkElement.insertAdjacentText("afterend", " with ");
|
|
175
|
+
} catch (error) {
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
</script></body></html>
|