utils-lib-js 1.0.14 → 1.1.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/dist/common/request.js +8 -4
- package/dist/esm/request.js +8 -4
- package/package.json +39 -39
package/dist/common/request.js
CHANGED
|
@@ -170,7 +170,7 @@ var RequestInit = function (_super) {
|
|
|
170
170
|
var _a, _b;
|
|
171
171
|
var params = _this.initAbort(_this.initDefaultParams(url, opts));
|
|
172
172
|
var options = (0, url_1.parse)(params.url, true);
|
|
173
|
-
return (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this, __assign(__assign({}, params), options))) !== null && _b !== void 0 ? _b : params;
|
|
173
|
+
return (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this, __assign(__assign({}, params), options))) !== null && _b !== void 0 ? _b : __assign(__assign({}, params), options);
|
|
174
174
|
};
|
|
175
175
|
return _this;
|
|
176
176
|
}
|
|
@@ -189,6 +189,9 @@ var Request = function (_super) {
|
|
|
189
189
|
url = _b.url,
|
|
190
190
|
opts = __rest(_b, ["url"]);
|
|
191
191
|
var signal = opts.signal;
|
|
192
|
+
promise.finally(function () {
|
|
193
|
+
return _this.clearTimer(opts);
|
|
194
|
+
});
|
|
192
195
|
signal.addEventListener('abort', function () {
|
|
193
196
|
return _this.errorFn(reject);
|
|
194
197
|
});
|
|
@@ -199,9 +202,7 @@ var Request = function (_super) {
|
|
|
199
202
|
return _this.errorFn(reject);
|
|
200
203
|
}).then(function (res) {
|
|
201
204
|
var _a, _b;return resolve((_b = (_a = _this.resFn) === null || _a === void 0 ? void 0 : _a.call(_this, res)) !== null && _b !== void 0 ? _b : res);
|
|
202
|
-
}).catch(_this.errorFn(reject))
|
|
203
|
-
return _this.clearTimer(opts);
|
|
204
|
-
});
|
|
205
|
+
}).catch(_this.errorFn(reject));
|
|
205
206
|
return promise;
|
|
206
207
|
};
|
|
207
208
|
_this.http = function (_url, _opts) {
|
|
@@ -211,6 +212,9 @@ var Request = function (_super) {
|
|
|
211
212
|
reject = _a.reject;
|
|
212
213
|
var params = _this.initHttpParams(_url, _opts);
|
|
213
214
|
var signal = params.signal;
|
|
215
|
+
promise.finally(function () {
|
|
216
|
+
return _this.clearTimer(params);
|
|
217
|
+
});
|
|
214
218
|
var req = (0, http_1.request)(params, function (response) {
|
|
215
219
|
if ((response === null || response === void 0 ? void 0 : response.statusCode) >= 200 && (response === null || response === void 0 ? void 0 : response.statusCode) < 300) {
|
|
216
220
|
var data_1 = "";
|
package/dist/esm/request.js
CHANGED
|
@@ -166,7 +166,7 @@ var RequestInit = function (_super) {
|
|
|
166
166
|
var _a, _b;
|
|
167
167
|
var params = _this.initAbort(_this.initDefaultParams(url, opts));
|
|
168
168
|
var options = parse(params.url, true);
|
|
169
|
-
return (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this, __assign(__assign({}, params), options))) !== null && _b !== void 0 ? _b : params;
|
|
169
|
+
return (_b = (_a = _this.reqFn) === null || _a === void 0 ? void 0 : _a.call(_this, __assign(__assign({}, params), options))) !== null && _b !== void 0 ? _b : __assign(__assign({}, params), options);
|
|
170
170
|
};
|
|
171
171
|
return _this;
|
|
172
172
|
}
|
|
@@ -185,6 +185,9 @@ var Request = function (_super) {
|
|
|
185
185
|
url = _b.url,
|
|
186
186
|
opts = __rest(_b, ["url"]);
|
|
187
187
|
var signal = opts.signal;
|
|
188
|
+
promise.finally(function () {
|
|
189
|
+
return _this.clearTimer(opts);
|
|
190
|
+
});
|
|
188
191
|
signal.addEventListener('abort', function () {
|
|
189
192
|
return _this.errorFn(reject);
|
|
190
193
|
});
|
|
@@ -195,9 +198,7 @@ var Request = function (_super) {
|
|
|
195
198
|
return _this.errorFn(reject);
|
|
196
199
|
}).then(function (res) {
|
|
197
200
|
var _a, _b;return resolve((_b = (_a = _this.resFn) === null || _a === void 0 ? void 0 : _a.call(_this, res)) !== null && _b !== void 0 ? _b : res);
|
|
198
|
-
}).catch(_this.errorFn(reject))
|
|
199
|
-
return _this.clearTimer(opts);
|
|
200
|
-
});
|
|
201
|
+
}).catch(_this.errorFn(reject));
|
|
201
202
|
return promise;
|
|
202
203
|
};
|
|
203
204
|
_this.http = function (_url, _opts) {
|
|
@@ -207,6 +208,9 @@ var Request = function (_super) {
|
|
|
207
208
|
reject = _a.reject;
|
|
208
209
|
var params = _this.initHttpParams(_url, _opts);
|
|
209
210
|
var signal = params.signal;
|
|
211
|
+
promise.finally(function () {
|
|
212
|
+
return _this.clearTimer(params);
|
|
213
|
+
});
|
|
210
214
|
var req = request(params, function (response) {
|
|
211
215
|
if ((response === null || response === void 0 ? void 0 : response.statusCode) >= 200 && (response === null || response === void 0 ? void 0 : response.statusCode) < 300) {
|
|
212
216
|
var data_1 = "";
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "utils-lib-js",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "JavaScript工具函数,封装的一些常用的js函数",
|
|
5
|
-
"main": "./dist/common/index.js",
|
|
6
|
-
"types": "./dist/common/index.d.ts",
|
|
7
|
-
"module": "./dist/esm/index.js",
|
|
8
|
-
"exports": {
|
|
9
|
-
"import": "./dist/esm/index.js",
|
|
10
|
-
"require": "./dist/common/index.js"
|
|
11
|
-
},
|
|
12
|
-
"scripts": {
|
|
13
|
-
"debug:esm": "start cmd /k pnpm run build:hot:esm",
|
|
14
|
-
"debug:node": "start cmd /k pnpm run build:hot:node & pnpm run node:hot",
|
|
15
|
-
"node:hot": "nodemon ./example/server.js",
|
|
16
|
-
"build:hot:esm": "tsc -p tsconfig.es.json -w",
|
|
17
|
-
"build:hot:node": "tsc -p tsconfig.json -w",
|
|
18
|
-
"build": "pnpm run tsc:build && pnpm run babel:mjs && pnpm run babel:cjs",
|
|
19
|
-
"tsc:build": "rm -fr dist && tsc -p tsconfig.json && tsc -p tsconfig.es.json",
|
|
20
|
-
"publish": "pnpm run build && pnpm publish",
|
|
21
|
-
"babel:mjs": "babel dist/esm --out-dir dist/esm",
|
|
22
|
-
"babel:cjs": "babel dist/common --out-dir dist/common",
|
|
23
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
24
|
-
},
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "https://gitee.com/DieHunter/utils-lib-js.git"
|
|
28
|
-
},
|
|
29
|
-
"keywords": [
|
|
30
|
-
"utils",
|
|
31
|
-
"tools",
|
|
32
|
-
"lib"
|
|
33
|
-
],
|
|
34
|
-
"author": "",
|
|
35
|
-
"license": "ISC",
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@types/node": "^18.7.15",
|
|
38
|
-
"babel-cli": "^6.26.0"
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "utils-lib-js",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "JavaScript工具函数,封装的一些常用的js函数",
|
|
5
|
+
"main": "./dist/common/index.js",
|
|
6
|
+
"types": "./dist/common/index.d.ts",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": "./dist/esm/index.js",
|
|
10
|
+
"require": "./dist/common/index.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"debug:esm": "start cmd /k pnpm run build:hot:esm",
|
|
14
|
+
"debug:node": "start cmd /k pnpm run build:hot:node & pnpm run node:hot",
|
|
15
|
+
"node:hot": "nodemon ./example/server.js",
|
|
16
|
+
"build:hot:esm": "tsc -p tsconfig.es.json -w",
|
|
17
|
+
"build:hot:node": "tsc -p tsconfig.json -w",
|
|
18
|
+
"build": "pnpm run tsc:build && pnpm run babel:mjs && pnpm run babel:cjs",
|
|
19
|
+
"tsc:build": "rm -fr dist && tsc -p tsconfig.json && tsc -p tsconfig.es.json",
|
|
20
|
+
"publish": "pnpm run build && pnpm publish",
|
|
21
|
+
"babel:mjs": "babel dist/esm --out-dir dist/esm",
|
|
22
|
+
"babel:cjs": "babel dist/common --out-dir dist/common",
|
|
23
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://gitee.com/DieHunter/utils-lib-js.git"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"utils",
|
|
31
|
+
"tools",
|
|
32
|
+
"lib"
|
|
33
|
+
],
|
|
34
|
+
"author": "",
|
|
35
|
+
"license": "ISC",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^18.7.15",
|
|
38
|
+
"babel-cli": "^6.26.0"
|
|
39
|
+
}
|
|
40
40
|
}
|