@jayfong/x-request 2.12.19 → 2.13.0
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/lib/_cjs/index.js +24 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +24 -0
- package/package.json +1 -1
package/lib/_cjs/index.js
CHANGED
|
@@ -190,6 +190,18 @@ class XRequest {
|
|
|
190
190
|
static isTimeoutError(err) {
|
|
191
191
|
return err instanceof _got.default.TimeoutError;
|
|
192
192
|
}
|
|
193
|
+
static formData(payload) {
|
|
194
|
+
return new XRequestFormData(payload);
|
|
195
|
+
}
|
|
196
|
+
static formStream(payload) {
|
|
197
|
+
return new XRequestFormStream(payload);
|
|
198
|
+
}
|
|
199
|
+
static formUrlencoded(payload) {
|
|
200
|
+
return new XRequestFormUrlencoded(payload);
|
|
201
|
+
}
|
|
202
|
+
static formFile(file, options) {
|
|
203
|
+
return new XRequestFormFile(file, options);
|
|
204
|
+
}
|
|
193
205
|
constructor(options) {
|
|
194
206
|
this.options = options;
|
|
195
207
|
}
|
|
@@ -236,5 +248,17 @@ class XRequest {
|
|
|
236
248
|
isTimeoutError(err) {
|
|
237
249
|
return XRequest.isTimeoutError(err);
|
|
238
250
|
}
|
|
251
|
+
formData(payload) {
|
|
252
|
+
return XRequest.formData(payload);
|
|
253
|
+
}
|
|
254
|
+
formStream(payload) {
|
|
255
|
+
return XRequest.formStream(payload);
|
|
256
|
+
}
|
|
257
|
+
formUrlencoded(payload) {
|
|
258
|
+
return XRequest.formUrlencoded(payload);
|
|
259
|
+
}
|
|
260
|
+
formFile(file, options) {
|
|
261
|
+
return XRequest.formFile(file, options);
|
|
262
|
+
}
|
|
239
263
|
}
|
|
240
264
|
exports.XRequest = XRequest;
|
package/lib/index.d.ts
CHANGED
|
@@ -110,6 +110,21 @@ export declare class XRequest {
|
|
|
110
110
|
static getStream(options: XRequestGetOptions): Request;
|
|
111
111
|
static postStream(options: XRequestPostStreamOptions): Request;
|
|
112
112
|
static isTimeoutError(err: any): boolean;
|
|
113
|
+
static formData(payload: ConstructorParameters<typeof XRequestFormData>[0]): XRequestFormData;
|
|
114
|
+
static formStream(payload: ConstructorParameters<typeof XRequestFormStream>[0]): XRequestFormStream;
|
|
115
|
+
static formUrlencoded(payload: ConstructorParameters<typeof XRequestFormUrlencoded>[0]): XRequestFormUrlencoded;
|
|
116
|
+
static formFile(file: Buffer, options: {
|
|
117
|
+
name: string;
|
|
118
|
+
type?: string;
|
|
119
|
+
}): XRequestFormFile;
|
|
120
|
+
static formFile(file: Readable, options: {
|
|
121
|
+
name: string;
|
|
122
|
+
type?: string;
|
|
123
|
+
}): XRequestFormFile;
|
|
124
|
+
static formFile(file: string, options?: {
|
|
125
|
+
name?: string;
|
|
126
|
+
type?: string;
|
|
127
|
+
}): XRequestFormFile;
|
|
113
128
|
constructor(options?: OmitStrict<XRequestOptions, 'url'>);
|
|
114
129
|
get(options: XRequestGetStreamOptions): Promise<XRequestResponse<Buffer>>;
|
|
115
130
|
get(options: XRequestGetStreamOptions, responseType: 'buffer'): Promise<XRequestResponse<Buffer>>;
|
|
@@ -128,4 +143,19 @@ export declare class XRequest {
|
|
|
128
143
|
getStream(options: XRequestGetOptions): Request;
|
|
129
144
|
postStream(options: XRequestPostStreamOptions): Request;
|
|
130
145
|
isTimeoutError(err: any): boolean;
|
|
146
|
+
formData(payload: ConstructorParameters<typeof XRequestFormData>[0]): XRequestFormData;
|
|
147
|
+
formStream(payload: ConstructorParameters<typeof XRequestFormStream>[0]): XRequestFormStream;
|
|
148
|
+
formUrlencoded(payload: ConstructorParameters<typeof XRequestFormUrlencoded>[0]): XRequestFormUrlencoded;
|
|
149
|
+
formFile(file: Buffer, options: {
|
|
150
|
+
name: string;
|
|
151
|
+
type?: string;
|
|
152
|
+
}): XRequestFormFile;
|
|
153
|
+
formFile(file: Readable, options: {
|
|
154
|
+
name: string;
|
|
155
|
+
type?: string;
|
|
156
|
+
}): XRequestFormFile;
|
|
157
|
+
formFile(file: string, options?: {
|
|
158
|
+
name?: string;
|
|
159
|
+
type?: string;
|
|
160
|
+
}): XRequestFormFile;
|
|
131
161
|
}
|
package/lib/index.js
CHANGED
|
@@ -181,6 +181,18 @@ export class XRequest {
|
|
|
181
181
|
static isTimeoutError(err) {
|
|
182
182
|
return err instanceof got.TimeoutError;
|
|
183
183
|
}
|
|
184
|
+
static formData(payload) {
|
|
185
|
+
return new XRequestFormData(payload);
|
|
186
|
+
}
|
|
187
|
+
static formStream(payload) {
|
|
188
|
+
return new XRequestFormStream(payload);
|
|
189
|
+
}
|
|
190
|
+
static formUrlencoded(payload) {
|
|
191
|
+
return new XRequestFormUrlencoded(payload);
|
|
192
|
+
}
|
|
193
|
+
static formFile(file, options) {
|
|
194
|
+
return new XRequestFormFile(file, options);
|
|
195
|
+
}
|
|
184
196
|
constructor(options) {
|
|
185
197
|
this.options = options;
|
|
186
198
|
}
|
|
@@ -227,4 +239,16 @@ export class XRequest {
|
|
|
227
239
|
isTimeoutError(err) {
|
|
228
240
|
return XRequest.isTimeoutError(err);
|
|
229
241
|
}
|
|
242
|
+
formData(payload) {
|
|
243
|
+
return XRequest.formData(payload);
|
|
244
|
+
}
|
|
245
|
+
formStream(payload) {
|
|
246
|
+
return XRequest.formStream(payload);
|
|
247
|
+
}
|
|
248
|
+
formUrlencoded(payload) {
|
|
249
|
+
return XRequest.formUrlencoded(payload);
|
|
250
|
+
}
|
|
251
|
+
formFile(file, options) {
|
|
252
|
+
return XRequest.formFile(file, options);
|
|
253
|
+
}
|
|
230
254
|
}
|