utils-lib-js 1.3.0 → 1.3.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/dist/common/index.js +1 -3
- package/dist/common/request.js +7 -4
- package/dist/esm/index.js +1 -3
- package/dist/esm/request.js +5 -2
- package/package.json +39 -39
- package/pnpm-lock.yaml +3 -3
package/dist/common/index.js
CHANGED
|
@@ -26,6 +26,4 @@ __exportStar(require("./static.js"), exports);
|
|
|
26
26
|
__exportStar(require("./types.js"), exports);
|
|
27
27
|
__exportStar(require("./request.js"), exports);
|
|
28
28
|
__exportStar(require("./event.js"), exports);
|
|
29
|
-
__exportStar(require("./storage.js"), exports);
|
|
30
|
-
console.log(require, typeof Window !== "undefined");
|
|
31
|
-
typeof require === "undefined" && typeof Window !== "undefined" && (window.require = function () {});
|
|
29
|
+
__exportStar(require("./storage.js"), exports);
|
package/dist/common/request.js
CHANGED
|
@@ -39,8 +39,11 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.Request = void 0;
|
|
41
41
|
var index_js_1 = require("./index.js");
|
|
42
|
-
var
|
|
43
|
-
|
|
42
|
+
var request, parse;
|
|
43
|
+
if (typeof require !== "undefined") {
|
|
44
|
+
request = require("http").request;
|
|
45
|
+
parse = require("url").parse;
|
|
46
|
+
}
|
|
44
47
|
var Interceptors = function () {
|
|
45
48
|
function Interceptors() {}
|
|
46
49
|
Interceptors.prototype.use = function (type, fn) {
|
|
@@ -188,7 +191,7 @@ var RequestInit = function (_super) {
|
|
|
188
191
|
_this.initHttpParams = function (url, opts) {
|
|
189
192
|
var _a, _b;
|
|
190
193
|
var params = _this.initAbort(_this.initDefaultParams(url, opts));
|
|
191
|
-
var options =
|
|
194
|
+
var options = parse(params.url, true);
|
|
192
195
|
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);
|
|
193
196
|
};
|
|
194
197
|
return _this;
|
|
@@ -234,7 +237,7 @@ var Request = function (_super) {
|
|
|
234
237
|
promise.finally(function () {
|
|
235
238
|
return _this.clearTimer(params);
|
|
236
239
|
});
|
|
237
|
-
var req =
|
|
240
|
+
var req = request(params, function (response) {
|
|
238
241
|
if ((response === null || response === void 0 ? void 0 : response.statusCode) >= 200 && (response === null || response === void 0 ? void 0 : response.statusCode) < 300) {
|
|
239
242
|
var data_1 = "";
|
|
240
243
|
response.setEncoding('utf8');
|
package/dist/esm/index.js
CHANGED
|
@@ -7,6 +7,4 @@ export * from "./static.js";
|
|
|
7
7
|
export * from "./types.js";
|
|
8
8
|
export * from "./request.js";
|
|
9
9
|
export * from "./event.js";
|
|
10
|
-
export * from "./storage.js";
|
|
11
|
-
console.log(require, typeof Window !== "undefined");
|
|
12
|
-
typeof require === "undefined" && typeof Window !== "undefined" && (window.require = function () {});
|
|
10
|
+
export * from "./storage.js";
|
package/dist/esm/request.js
CHANGED
|
@@ -35,8 +35,11 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
35
35
|
return t;
|
|
36
36
|
};
|
|
37
37
|
import { urlJoin, defer, jsonToString, stringToJson } from "./index.js";
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
var request, parse;
|
|
39
|
+
if (typeof require !== "undefined") {
|
|
40
|
+
request = require("http").request;
|
|
41
|
+
parse = require("url").parse;
|
|
42
|
+
}
|
|
40
43
|
var Interceptors = function () {
|
|
41
44
|
function Interceptors() {}
|
|
42
45
|
Interceptors.prototype.use = function (type, fn) {
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "utils-lib-js",
|
|
3
|
-
"version": "1.3.
|
|
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
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "utils-lib-js",
|
|
3
|
+
"version": "1.3.1",
|
|
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
|
}
|
package/pnpm-lock.yaml
CHANGED
|
@@ -5,13 +5,13 @@ specifiers:
|
|
|
5
5
|
babel-cli: ^6.26.0
|
|
6
6
|
|
|
7
7
|
devDependencies:
|
|
8
|
-
'@types/node': 18.
|
|
8
|
+
'@types/node': 18.11.9
|
|
9
9
|
babel-cli: 6.26.0
|
|
10
10
|
|
|
11
11
|
packages:
|
|
12
12
|
|
|
13
|
-
/@types/node/18.
|
|
14
|
-
resolution: {integrity: sha512-
|
|
13
|
+
/@types/node/18.11.9:
|
|
14
|
+
resolution: {integrity: sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==}
|
|
15
15
|
dev: true
|
|
16
16
|
|
|
17
17
|
/ansi-regex/2.1.1:
|