@zwa73/utils 1.0.176 → 1.0.178
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/dist/UtilCom.d.ts +5 -5
- package/dist/UtilCom.js +2 -2
- package/package.json +1 -1
- package/src/UtilCom.ts +6 -7
package/dist/UtilCom.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export type GetReqData = NodeJS.Dict<string | number | boolean | readonly string
|
|
|
39
39
|
export declare namespace UtilCom {
|
|
40
40
|
/**网络请求
|
|
41
41
|
* @param comReqOpt - 网络请求选项
|
|
42
|
-
* @param procReq - 请求处理函数
|
|
42
|
+
* @param procReq - 请求处理函数 需调用req.end()
|
|
43
43
|
* @param reduceData - 数据处理函数
|
|
44
44
|
* @param initData - 初始数据
|
|
45
45
|
*/
|
|
@@ -50,7 +50,7 @@ export declare namespace UtilCom {
|
|
|
50
50
|
* @param reqData - 数据对象
|
|
51
51
|
* @returns 结果 undefined 为未能成功接收
|
|
52
52
|
*/
|
|
53
|
-
function httpsPost(comReqOpt: Omit<ComReqOpt, 'protocol' | 'method'>, reqData
|
|
53
|
+
function httpsPost(comReqOpt: Omit<ComReqOpt, 'protocol' | 'method'>, reqData?: JObject): Promise<{
|
|
54
54
|
data: JObject;
|
|
55
55
|
/**响应头 */
|
|
56
56
|
headers: http.IncomingHttpHeaders;
|
|
@@ -63,7 +63,7 @@ export declare namespace UtilCom {
|
|
|
63
63
|
* @param reqData - 数据对象
|
|
64
64
|
* @returns 结果 undefined 为未能成功接收
|
|
65
65
|
*/
|
|
66
|
-
function httpPost(comReqOpt: Omit<ComReqOpt, 'protocol' | 'method'>, reqData
|
|
66
|
+
function httpPost(comReqOpt: Omit<ComReqOpt, 'protocol' | 'method'>, reqData?: JObject): Promise<{
|
|
67
67
|
data: JObject;
|
|
68
68
|
/**响应头 */
|
|
69
69
|
headers: http.IncomingHttpHeaders;
|
|
@@ -76,7 +76,7 @@ export declare namespace UtilCom {
|
|
|
76
76
|
* @param reqData - 数据对象
|
|
77
77
|
* @returns 结果 undefined 为未能成功接收
|
|
78
78
|
*/
|
|
79
|
-
function httpsGet(comReqOpt: Omit<ComReqOpt, 'protocol' | 'method'>, reqData
|
|
79
|
+
function httpsGet(comReqOpt: Omit<ComReqOpt, 'protocol' | 'method'>, reqData?: GetReqData): Promise<{
|
|
80
80
|
data: JObject;
|
|
81
81
|
/**响应头 */
|
|
82
82
|
headers: http.IncomingHttpHeaders;
|
|
@@ -89,7 +89,7 @@ export declare namespace UtilCom {
|
|
|
89
89
|
* @param reqData - 数据对象
|
|
90
90
|
* @returns 结果 undefined 为未能成功接收
|
|
91
91
|
*/
|
|
92
|
-
function httpGet(comReqOpt: Omit<ComReqOpt, 'protocol' | 'method'>, reqData
|
|
92
|
+
function httpGet(comReqOpt: Omit<ComReqOpt, 'protocol' | 'method'>, reqData?: GetReqData): Promise<{
|
|
93
93
|
data: JObject;
|
|
94
94
|
/**响应头 */
|
|
95
95
|
headers: http.IncomingHttpHeaders;
|
package/dist/UtilCom.js
CHANGED
|
@@ -14,7 +14,7 @@ var UtilCom;
|
|
|
14
14
|
(function (UtilCom) {
|
|
15
15
|
/**网络请求
|
|
16
16
|
* @param comReqOpt - 网络请求选项
|
|
17
|
-
* @param procReq - 请求处理函数
|
|
17
|
+
* @param procReq - 请求处理函数 需调用req.end()
|
|
18
18
|
* @param reduceData - 数据处理函数
|
|
19
19
|
* @param initData - 初始数据
|
|
20
20
|
*/
|
|
@@ -75,7 +75,6 @@ var UtilCom;
|
|
|
75
75
|
resolve(undefined);
|
|
76
76
|
});
|
|
77
77
|
await procReq(req);
|
|
78
|
-
req.end();
|
|
79
78
|
});
|
|
80
79
|
}
|
|
81
80
|
UtilCom.comReq = comReq;
|
|
@@ -92,6 +91,7 @@ var UtilCom;
|
|
|
92
91
|
const procReq = (req) => {
|
|
93
92
|
if (isPost)
|
|
94
93
|
req.write(JSON.stringify(reqData));
|
|
94
|
+
req.end();
|
|
95
95
|
};
|
|
96
96
|
const reduceData = (acc, data) => acc + data;
|
|
97
97
|
const result = await comReq(comReqOpt, procReq, reduceData, "");
|
package/package.json
CHANGED
package/src/UtilCom.ts
CHANGED
|
@@ -56,7 +56,7 @@ export namespace UtilCom{
|
|
|
56
56
|
|
|
57
57
|
/**网络请求
|
|
58
58
|
* @param comReqOpt - 网络请求选项
|
|
59
|
-
* @param procReq - 请求处理函数
|
|
59
|
+
* @param procReq - 请求处理函数 需调用req.end()
|
|
60
60
|
* @param reduceData - 数据处理函数
|
|
61
61
|
* @param initData - 初始数据
|
|
62
62
|
*/
|
|
@@ -130,8 +130,6 @@ export async function comReq<T>(
|
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
await procReq(req);
|
|
133
|
-
|
|
134
|
-
req.end();
|
|
135
133
|
});
|
|
136
134
|
}
|
|
137
135
|
|
|
@@ -151,6 +149,7 @@ async function jsonReq<T extends ComReqOpt>(
|
|
|
151
149
|
|
|
152
150
|
const procReq = (req:http.ClientRequest)=>{
|
|
153
151
|
if(isPost) req.write(JSON.stringify(reqData));
|
|
152
|
+
req.end();
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
const reduceData = (acc:string,data:string)=>acc+data;
|
|
@@ -199,7 +198,7 @@ async function repeatJsonComReq<T extends ComReqOpt>(
|
|
|
199
198
|
* @param reqData - 数据对象
|
|
200
199
|
* @returns 结果 undefined 为未能成功接收
|
|
201
200
|
*/
|
|
202
|
-
export function httpsPost(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData
|
|
201
|
+
export function httpsPost(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData?:JObject){
|
|
203
202
|
return jsonReq({
|
|
204
203
|
...comReqOpt,
|
|
205
204
|
method:"POST",
|
|
@@ -213,7 +212,7 @@ export function httpsPost(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData:
|
|
|
213
212
|
* @param reqData - 数据对象
|
|
214
213
|
* @returns 结果 undefined 为未能成功接收
|
|
215
214
|
*/
|
|
216
|
-
export function httpPost(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData
|
|
215
|
+
export function httpPost(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData?:JObject){
|
|
217
216
|
return jsonReq({
|
|
218
217
|
...comReqOpt,
|
|
219
218
|
method:"POST",
|
|
@@ -227,7 +226,7 @@ export function httpPost(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData:J
|
|
|
227
226
|
* @param reqData - 数据对象
|
|
228
227
|
* @returns 结果 undefined 为未能成功接收
|
|
229
228
|
*/
|
|
230
|
-
export function httpsGet(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData
|
|
229
|
+
export function httpsGet(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData?:GetReqData){
|
|
231
230
|
return jsonReq({
|
|
232
231
|
...comReqOpt,
|
|
233
232
|
method:"GET",
|
|
@@ -241,7 +240,7 @@ export function httpsGet(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData:R
|
|
|
241
240
|
* @param reqData - 数据对象
|
|
242
241
|
* @returns 结果 undefined 为未能成功接收
|
|
243
242
|
*/
|
|
244
|
-
export function httpGet(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData
|
|
243
|
+
export function httpGet(comReqOpt:Omit<ComReqOpt,'protocol'|'method'>,reqData?:GetReqData){
|
|
245
244
|
return jsonReq({
|
|
246
245
|
...comReqOpt,
|
|
247
246
|
method:"GET",
|