kbfetch 1.0.0 → 1.0.2
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 +4 -3
- package/dist/index.js +3 -3
- package/dist/typings/index.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -35,7 +35,9 @@ kbfetch.g('https://baidu.com', { method: 'PATCH' })
|
|
|
35
35
|
const ft = kbfetch.post('https://api.example.com/data', { id: 1 }, { canAbort: true })
|
|
36
36
|
ft.abort()
|
|
37
37
|
```
|
|
38
|
+
|
|
38
39
|
`or`
|
|
40
|
+
|
|
39
41
|
```js
|
|
40
42
|
const ft = kbfetch.g('https://api.example.com/data', { params: { id: 1 }, timeout: 0 })
|
|
41
43
|
ft.abort()
|
|
@@ -51,8 +53,6 @@ kbfetch.baseParams = { access_token: 'xxx' }
|
|
|
51
53
|
kbfetch.baseBody = { access_token: 'xxx' }
|
|
52
54
|
```
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
56
|
### 方法汇总
|
|
57
57
|
|
|
58
58
|
```
|
|
@@ -83,7 +83,8 @@ uploadFile: (url: string, file: File, init?: KbFetchInit)
|
|
|
83
83
|
- `after` - 响应结果的回调函数
|
|
84
84
|
|
|
85
85
|
```typescript
|
|
86
|
-
import kbfetch, { createKbFetch } from 'kbfetch'
|
|
86
|
+
import kbfetch, { createKbFetch, kbfc } from 'kbfetch'
|
|
87
|
+
// kbfc等同于kbfetch
|
|
87
88
|
// 请求单独配置
|
|
88
89
|
kbfetch.post(url, data, kbFetchInit)
|
|
89
90
|
kbfetch.get(url, params, kbFetchInit)
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var help = {
|
|
|
20
20
|
return headers;
|
|
21
21
|
},
|
|
22
22
|
urlWithProtocol: (url) => url.startsWith("http://") || url.startsWith("https://"),
|
|
23
|
-
addProtocol: (url) => !url || !
|
|
23
|
+
addProtocol: (url) => !url || !globalThis.location || help.urlWithProtocol(url) ? url : location.protocol + url,
|
|
24
24
|
objPick: (obj, keys) => Object.fromEntries(keys.map((key) => [key, obj[key]])),
|
|
25
25
|
objSetDefVal: (obj, key, def) => def && (obj[key] = Object.assign({}, def, obj[key]))
|
|
26
26
|
};
|
|
@@ -92,9 +92,9 @@ var createKbFetch = (config) => ({
|
|
|
92
92
|
});
|
|
93
93
|
var kbfetch = defaultKbFetch;
|
|
94
94
|
var kbfetch_default = kbfetch;
|
|
95
|
-
var
|
|
95
|
+
var kbfc = kbfetch;
|
|
96
96
|
export {
|
|
97
|
-
|
|
97
|
+
kbfc,
|
|
98
98
|
kbfetch_default as default,
|
|
99
99
|
createKbFetch
|
|
100
100
|
};
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -33,4 +33,4 @@ export declare const createKbFetch: (config: Partial<Pick<DefaultKbFetch, "baseU
|
|
|
33
33
|
};
|
|
34
34
|
declare const kbfetch: Omit<DefaultKbFetch, "do">;
|
|
35
35
|
export default kbfetch;
|
|
36
|
-
export declare const
|
|
36
|
+
export declare const kbfc: Omit<DefaultKbFetch, "do">;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kbfetch",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"devDependencies": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"scripts": {
|
|
24
|
-
"pub": "bun bld && bun tsc
|
|
24
|
+
"pub": "bun bld && bun tsc && npm publish --registry https://registry.npmjs.org/ ; bun updatetaobao ",
|
|
25
25
|
"patch": "git stash && npm version patch && git stash pop",
|
|
26
26
|
"updatetaobao": "cnpm sync kbfetch",
|
|
27
27
|
"tsc": "tsc index.ts -d --emitDeclarationOnly --declarationDir ./dist/typings",
|