stream-axios 1.0.0 → 1.0.1
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 +7 -7
- package/README.zh-CN.md +7 -7
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# axios
|
|
1
|
+
# stream-axios
|
|
2
2
|
|
|
3
3
|
[English](./README.md) | [简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
@@ -14,7 +14,7 @@ A wrapper library based on axios that retains the original configuration capabil
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install axios
|
|
17
|
+
npm install stream-axios
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Usage Guide
|
|
@@ -22,7 +22,7 @@ npm install axios-stream
|
|
|
22
22
|
### 1. Basic Request (Same as axios)
|
|
23
23
|
|
|
24
24
|
```javascript
|
|
25
|
-
import request from "axios
|
|
25
|
+
import request from "stream-axios";
|
|
26
26
|
|
|
27
27
|
// GET request
|
|
28
28
|
request
|
|
@@ -53,7 +53,7 @@ request
|
|
|
53
53
|
Suitable for scenarios like receiving large files or AI conversation streams.
|
|
54
54
|
|
|
55
55
|
```javascript
|
|
56
|
-
import request from "axios
|
|
56
|
+
import request from "stream-axios";
|
|
57
57
|
|
|
58
58
|
const cancel = request.stream(
|
|
59
59
|
{
|
|
@@ -84,7 +84,7 @@ const cancel = request.stream(
|
|
|
84
84
|
If you need independent configuration or interceptors:
|
|
85
85
|
|
|
86
86
|
```javascript
|
|
87
|
-
import { createInstance } from "axios
|
|
87
|
+
import { createInstance } from "stream-axios";
|
|
88
88
|
|
|
89
89
|
const myRequest = createInstance({
|
|
90
90
|
baseURL: "https://api.mydomain.com",
|
|
@@ -106,7 +106,7 @@ myRequest.stream({ url: "/stream" }, (chunk) => console.log(chunk));
|
|
|
106
106
|
If you are handling SSE (Server-Sent Events) format data:
|
|
107
107
|
|
|
108
108
|
```javascript
|
|
109
|
-
import request, { parseSSEChunk } from "axios
|
|
109
|
+
import request, { parseSSEChunk } from "stream-axios";
|
|
110
110
|
|
|
111
111
|
request.stream({ url: "/sse-endpoint", method: "GET" }, (chunk) => {
|
|
112
112
|
// Parse SSE data
|
|
@@ -122,7 +122,7 @@ If you already have a configured axios instance in your project, you can attach
|
|
|
122
122
|
|
|
123
123
|
```javascript
|
|
124
124
|
import axios from "axios";
|
|
125
|
-
import { attachStream } from "axios
|
|
125
|
+
import { attachStream } from "stream-axios";
|
|
126
126
|
|
|
127
127
|
// Your existing axios instance
|
|
128
128
|
const myAxios = axios.create({
|
package/README.zh-CN.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# axios
|
|
1
|
+
# stream-axios
|
|
2
2
|
|
|
3
3
|
[English](./README.md) | [简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
## 安装
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install axios
|
|
17
|
+
npm install stream-axios
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## 使用指南
|
|
@@ -22,7 +22,7 @@ npm install axios-stream
|
|
|
22
22
|
### 1. 基础请求 (同 axios)
|
|
23
23
|
|
|
24
24
|
```javascript
|
|
25
|
-
import request from 'axios
|
|
25
|
+
import request from 'stream-axios';
|
|
26
26
|
|
|
27
27
|
// GET 请求
|
|
28
28
|
request.get('/user?ID=12345')
|
|
@@ -51,7 +51,7 @@ request.post('/user', {
|
|
|
51
51
|
适用于接收大文件或 AI 对话流等场景。
|
|
52
52
|
|
|
53
53
|
```javascript
|
|
54
|
-
import request from 'axios
|
|
54
|
+
import request from 'stream-axios';
|
|
55
55
|
|
|
56
56
|
const cancel = request.stream(
|
|
57
57
|
{
|
|
@@ -82,7 +82,7 @@ const cancel = request.stream(
|
|
|
82
82
|
如果你需要独立的配置或拦截器:
|
|
83
83
|
|
|
84
84
|
```javascript
|
|
85
|
-
import { createInstance } from 'axios
|
|
85
|
+
import { createInstance } from 'stream-axios';
|
|
86
86
|
|
|
87
87
|
const myRequest = createInstance({
|
|
88
88
|
baseURL: 'https://api.mydomain.com',
|
|
@@ -104,7 +104,7 @@ myRequest.stream({ url: '/stream' }, (chunk) => console.log(chunk));
|
|
|
104
104
|
如果你处理的是 SSE (Server-Sent Events) 格式的数据:
|
|
105
105
|
|
|
106
106
|
```javascript
|
|
107
|
-
import request, { parseSSEChunk } from 'axios
|
|
107
|
+
import request, { parseSSEChunk } from 'stream-axios';
|
|
108
108
|
|
|
109
109
|
request.stream(
|
|
110
110
|
{ url: '/sse-endpoint', method: 'GET' },
|
|
@@ -123,7 +123,7 @@ request.stream(
|
|
|
123
123
|
|
|
124
124
|
```javascript
|
|
125
125
|
import axios from 'axios';
|
|
126
|
-
import { attachStream } from 'axios
|
|
126
|
+
import { attachStream } from 'stream-axios';
|
|
127
127
|
|
|
128
128
|
// 你现有的 axios 实例
|
|
129
129
|
const myAxios = axios.create({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-axios",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "二次封装 axios,保留原始配置,提供流式接口,提升开发效率",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
},
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
39
|
-
"url": "git+https://github.com/zOvOp/axios
|
|
39
|
+
"url": "git+https://github.com/zOvOp/stream-axios.git"
|
|
40
40
|
},
|
|
41
41
|
"bugs": {
|
|
42
|
-
"url": "https://github.com/zOvOp/axios
|
|
42
|
+
"url": "https://github.com/zOvOp/stream-axios/issues"
|
|
43
43
|
},
|
|
44
|
-
"homepage": "https://github.com/zOvOp/axios
|
|
44
|
+
"homepage": "https://github.com/zOvOp/stream-axios#readme",
|
|
45
45
|
"author": "zovop",
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
53
53
|
"rollup": "^4.57.1"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|