ee-core 4.1.3 → 4.1.4
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/LICENSE +21 -21
- package/README.md +65 -65
- package/app/application.d.ts +5 -5
- package/app/application.js +30 -30
- package/app/boot.d.ts +5 -5
- package/app/boot.js +80 -80
- package/app/dir.d.ts +1 -1
- package/app/dir.js +26 -26
- package/app/events.d.ts +14 -14
- package/app/events.js +55 -55
- package/app/index.d.ts +2 -2
- package/app/index.js +6 -6
- package/config/config_loader.d.ts +13 -13
- package/config/config_loader.js +65 -65
- package/config/default_config.d.ts +95 -95
- package/config/default_config.js +111 -111
- package/config/index.d.ts +28 -28
- package/config/index.js +24 -24
- package/const/channel.d.ts +16 -16
- package/const/channel.js +27 -27
- package/controller/controller_loader.d.ts +9 -9
- package/controller/controller_loader.js +77 -77
- package/controller/index.d.ts +2 -2
- package/controller/index.js +24 -24
- package/core/index.d.ts +2 -2
- package/core/index.js +11 -11
- package/core/loader/file_loader.d.ts +66 -66
- package/core/loader/file_loader.js +211 -211
- package/core/utils/index.d.ts +12 -12
- package/core/utils/index.js +83 -83
- package/core/utils/timing.d.ts +22 -22
- package/core/utils/timing.js +78 -78
- package/cross/cross.d.ts +19 -19
- package/cross/cross.js +151 -151
- package/cross/crossProcess.d.ts +29 -29
- package/cross/crossProcess.js +172 -172
- package/cross/index.d.ts +2 -2
- package/cross/index.js +8 -8
- package/electron/app/index.d.ts +5 -5
- package/electron/app/index.js +48 -48
- package/electron/index.d.ts +3 -3
- package/electron/index.js +15 -15
- package/electron/window/index.d.ts +6 -6
- package/electron/window/index.js +268 -268
- package/exception/index.d.ts +9 -9
- package/exception/index.js +100 -100
- package/html/boot.html +98 -98
- package/html/cross-failure.html +28 -28
- package/html/failure.html +28 -28
- package/html/index.d.ts +1 -1
- package/html/index.js +10 -10
- package/index.d.ts +2 -2
- package/index.js +6 -6
- package/jobs/child/app.d.ts +1 -1
- package/jobs/child/app.js +69 -69
- package/jobs/child/index.d.ts +13 -13
- package/jobs/child/index.js +85 -85
- package/jobs/child/jobProcess.d.ts +16 -16
- package/jobs/child/jobProcess.js +133 -133
- package/jobs/child-pool/index.d.ts +26 -26
- package/jobs/child-pool/index.js +190 -190
- package/jobs/index.d.ts +3 -3
- package/jobs/index.js +6 -6
- package/jobs/load-balancer/algorithm/index.d.ts +4 -4
- package/jobs/load-balancer/algorithm/index.js +11 -11
- package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
- package/jobs/load-balancer/algorithm/polling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/polling.js +11 -11
- package/jobs/load-balancer/algorithm/random.d.ts +2 -2
- package/jobs/load-balancer/algorithm/random.js +9 -9
- package/jobs/load-balancer/algorithm/specify.d.ts +2 -2
- package/jobs/load-balancer/algorithm/specify.js +14 -14
- package/jobs/load-balancer/algorithm/weights.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weights.js +21 -21
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
- package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
- package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -2
- package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
- package/jobs/load-balancer/consts.d.ts +8 -8
- package/jobs/load-balancer/consts.js +9 -9
- package/jobs/load-balancer/index.d.ts +96 -96
- package/jobs/load-balancer/index.js +201 -201
- package/jobs/load-balancer/scheduler.d.ts +16 -16
- package/jobs/load-balancer/scheduler.js +31 -31
- package/loader/index.d.ts +9 -9
- package/loader/index.js +99 -98
- package/log/index.d.ts +5 -5
- package/log/index.js +85 -85
- package/log/logger.d.ts +1 -1
- package/log/logger.js +94 -94
- package/message/childMessage.d.ts +10 -10
- package/message/childMessage.js +43 -43
- package/message/index.d.ts +3 -3
- package/message/index.js +9 -9
- package/package.json +42 -42
- package/ps/index.d.ts +39 -39
- package/ps/index.js +294 -294
- package/socket/httpServer.d.ts +8 -8
- package/socket/httpServer.js +199 -199
- package/socket/index.d.ts +10 -10
- package/socket/index.js +64 -64
- package/socket/ipcServer.d.ts +9 -9
- package/socket/ipcServer.js +105 -105
- package/socket/socketServer.d.ts +10 -10
- package/socket/socketServer.js +81 -81
- package/storage/index.d.ts +4 -4
- package/storage/index.js +6 -6
- package/storage/sqliteStorage.d.ts +16 -16
- package/storage/sqliteStorage.js +123 -123
- package/tsconfig.json +13 -13
- package/utils/extend.d.ts +2 -2
- package/utils/extend.js +77 -77
- package/utils/helper.d.ts +14 -14
- package/utils/helper.js +206 -206
- package/utils/index.d.ts +10 -10
- package/utils/index.js +167 -167
- package/utils/ip.d.ts +2 -2
- package/utils/ip.js +221 -221
- package/utils/is.d.ts +14 -14
- package/utils/is.js +111 -111
- package/utils/json.d.ts +5 -5
- package/utils/json.js +79 -79
- package/utils/pargv.d.ts +3 -3
- package/utils/pargv.js +267 -267
- package/utils/port/index.d.ts +1 -1
- package/utils/port/index.js +125 -125
- package/utils/wrap.d.ts +4 -4
- package/utils/wrap.js +40 -40
package/storage/sqliteStorage.js
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const assert = require('assert');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const BSqlite = require('better-sqlite3');
|
|
7
|
-
const { mkdir } = require('../utils/helper');
|
|
8
|
-
const { getDataDir } = require('../ps');
|
|
9
|
-
|
|
10
|
-
class SqliteStorage {
|
|
11
|
-
constructor (name, opt = {}) {
|
|
12
|
-
assert(name, `db name ${name} Cannot be empty`);
|
|
13
|
-
|
|
14
|
-
this.name = name;
|
|
15
|
-
this.mode = this.getMode(name);
|
|
16
|
-
this.dbDir = this._createDatabaseDir();
|
|
17
|
-
this.fileName = this._formatFileName(name);
|
|
18
|
-
this.db = this._initDB(opt);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 初始化db
|
|
23
|
-
*/
|
|
24
|
-
_initDB (opt = {}) {
|
|
25
|
-
let options = Object.assign({
|
|
26
|
-
timeout: 5000,
|
|
27
|
-
}, opt);
|
|
28
|
-
|
|
29
|
-
// 存储类型:db文件、内存(:memory:)
|
|
30
|
-
let dbPath = this.name;
|
|
31
|
-
if (this.mode != 'memory') {
|
|
32
|
-
dbPath = this.getFilePath();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const db = new BSqlite(dbPath, options);
|
|
36
|
-
|
|
37
|
-
// 如果是文件类型,判断文件是否创建成功
|
|
38
|
-
if (this.mode != 'memory') {
|
|
39
|
-
assert(fs.existsSync(dbPath), `error: db ${dbPath} not exists`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return db;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 获取文件名
|
|
47
|
-
*/
|
|
48
|
-
_formatFileName (name) {
|
|
49
|
-
let fileName = name;
|
|
50
|
-
if (this.mode != 'memory') {
|
|
51
|
-
fileName = path.basename(name);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return fileName;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 创建storage目录
|
|
59
|
-
*/
|
|
60
|
-
_createDatabaseDir () {
|
|
61
|
-
let dbDir = path.join(getDataDir(), 'db');
|
|
62
|
-
if (this.mode == 'absolute') {
|
|
63
|
-
dbDir = path.dirname(this.name);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!fs.existsSync(dbDir)) {
|
|
67
|
-
mkdir(dbDir, { mode: 0o755 });
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return dbDir;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* 获取file path 模式
|
|
75
|
-
*/
|
|
76
|
-
getMode (name) {
|
|
77
|
-
let mode = '';
|
|
78
|
-
|
|
79
|
-
// 内存模式
|
|
80
|
-
if (name == ':memory:') {
|
|
81
|
-
mode = 'memory';
|
|
82
|
-
return mode;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
assert(path.extname(name) == '.db', `error: db ${name} file ext name must be .db`);
|
|
86
|
-
|
|
87
|
-
// 路径模式
|
|
88
|
-
name = name.replace(/[/\\]/g, '/');
|
|
89
|
-
if (name.indexOf('/') !== -1) {
|
|
90
|
-
const isAbsolute = path.isAbsolute(name);
|
|
91
|
-
if (isAbsolute) {
|
|
92
|
-
mode = 'absolute';
|
|
93
|
-
} else {
|
|
94
|
-
mode = 'relative';
|
|
95
|
-
}
|
|
96
|
-
return mode;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 仅文件名
|
|
100
|
-
mode = 'onlyName';
|
|
101
|
-
|
|
102
|
-
return mode;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 获取 db 文件目录
|
|
107
|
-
*/
|
|
108
|
-
getDbDir () {
|
|
109
|
-
return this.dbDir;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 获取文件绝对路径
|
|
114
|
-
*/
|
|
115
|
-
getFilePath () {
|
|
116
|
-
const dbFile = path.join(this.dbDir, this.fileName);
|
|
117
|
-
|
|
118
|
-
return dbFile;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
module.exports = {
|
|
123
|
-
SqliteStorage
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const BSqlite = require('better-sqlite3');
|
|
7
|
+
const { mkdir } = require('../utils/helper');
|
|
8
|
+
const { getDataDir } = require('../ps');
|
|
9
|
+
|
|
10
|
+
class SqliteStorage {
|
|
11
|
+
constructor (name, opt = {}) {
|
|
12
|
+
assert(name, `db name ${name} Cannot be empty`);
|
|
13
|
+
|
|
14
|
+
this.name = name;
|
|
15
|
+
this.mode = this.getMode(name);
|
|
16
|
+
this.dbDir = this._createDatabaseDir();
|
|
17
|
+
this.fileName = this._formatFileName(name);
|
|
18
|
+
this.db = this._initDB(opt);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 初始化db
|
|
23
|
+
*/
|
|
24
|
+
_initDB (opt = {}) {
|
|
25
|
+
let options = Object.assign({
|
|
26
|
+
timeout: 5000,
|
|
27
|
+
}, opt);
|
|
28
|
+
|
|
29
|
+
// 存储类型:db文件、内存(:memory:)
|
|
30
|
+
let dbPath = this.name;
|
|
31
|
+
if (this.mode != 'memory') {
|
|
32
|
+
dbPath = this.getFilePath();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const db = new BSqlite(dbPath, options);
|
|
36
|
+
|
|
37
|
+
// 如果是文件类型,判断文件是否创建成功
|
|
38
|
+
if (this.mode != 'memory') {
|
|
39
|
+
assert(fs.existsSync(dbPath), `error: db ${dbPath} not exists`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return db;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 获取文件名
|
|
47
|
+
*/
|
|
48
|
+
_formatFileName (name) {
|
|
49
|
+
let fileName = name;
|
|
50
|
+
if (this.mode != 'memory') {
|
|
51
|
+
fileName = path.basename(name);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return fileName;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 创建storage目录
|
|
59
|
+
*/
|
|
60
|
+
_createDatabaseDir () {
|
|
61
|
+
let dbDir = path.join(getDataDir(), 'db');
|
|
62
|
+
if (this.mode == 'absolute') {
|
|
63
|
+
dbDir = path.dirname(this.name);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!fs.existsSync(dbDir)) {
|
|
67
|
+
mkdir(dbDir, { mode: 0o755 });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return dbDir;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 获取file path 模式
|
|
75
|
+
*/
|
|
76
|
+
getMode (name) {
|
|
77
|
+
let mode = '';
|
|
78
|
+
|
|
79
|
+
// 内存模式
|
|
80
|
+
if (name == ':memory:') {
|
|
81
|
+
mode = 'memory';
|
|
82
|
+
return mode;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
assert(path.extname(name) == '.db', `error: db ${name} file ext name must be .db`);
|
|
86
|
+
|
|
87
|
+
// 路径模式
|
|
88
|
+
name = name.replace(/[/\\]/g, '/');
|
|
89
|
+
if (name.indexOf('/') !== -1) {
|
|
90
|
+
const isAbsolute = path.isAbsolute(name);
|
|
91
|
+
if (isAbsolute) {
|
|
92
|
+
mode = 'absolute';
|
|
93
|
+
} else {
|
|
94
|
+
mode = 'relative';
|
|
95
|
+
}
|
|
96
|
+
return mode;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 仅文件名
|
|
100
|
+
mode = 'onlyName';
|
|
101
|
+
|
|
102
|
+
return mode;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 获取 db 文件目录
|
|
107
|
+
*/
|
|
108
|
+
getDbDir () {
|
|
109
|
+
return this.dbDir;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 获取文件绝对路径
|
|
114
|
+
*/
|
|
115
|
+
getFilePath () {
|
|
116
|
+
const dbFile = path.join(this.dbDir, this.fileName);
|
|
117
|
+
|
|
118
|
+
return dbFile;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = {
|
|
123
|
+
SqliteStorage
|
|
124
124
|
};
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"skipLibCheck": true,
|
|
4
|
-
"allowJs": true,
|
|
5
|
-
"emitDeclarationOnly": true,
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"outDir": "types",
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"index.js", "app", "config", "const", "controller", "core", "cross", "electron", "exception",
|
|
11
|
-
"html", "jobs", "loader", "log", "message", "ps", "socket", "storage", "utils",
|
|
12
|
-
]
|
|
13
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"skipLibCheck": true,
|
|
4
|
+
"allowJs": true,
|
|
5
|
+
"emitDeclarationOnly": true,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"outDir": "types",
|
|
8
|
+
},
|
|
9
|
+
"include": [
|
|
10
|
+
"index.js", "app", "config", "const", "controller", "core", "cross", "electron", "exception",
|
|
11
|
+
"html", "jobs", "loader", "log", "message", "ps", "socket", "storage", "utils",
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
14
|
|
package/utils/extend.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function extend(...args: any[]): any;
|
|
2
|
-
export declare function isPlainObject(obj: any): any;
|
|
1
|
+
export declare function extend(...args: any[]): any;
|
|
2
|
+
export declare function isPlainObject(obj: any): any;
|
package/utils/extend.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const hasOwn = Object.prototype.hasOwnProperty;
|
|
4
|
-
const toStr = Object.prototype.toString;
|
|
5
|
-
|
|
6
|
-
function isPlainObject(obj) {
|
|
7
|
-
if (!obj || toStr.call(obj) !== '[object Object]') {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
|
|
12
|
-
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
|
|
13
|
-
// Not own constructor property must be Object
|
|
14
|
-
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Own properties are enumerated firstly, so to speed up,
|
|
19
|
-
// if last one is own, then all properties are own.
|
|
20
|
-
var key;
|
|
21
|
-
for (key in obj) { /**/ }
|
|
22
|
-
|
|
23
|
-
return typeof key === 'undefined' || hasOwn.call(obj, key);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function extend() {
|
|
27
|
-
var options, name, src, copy, clone;
|
|
28
|
-
var target = arguments[0];
|
|
29
|
-
var i = 1;
|
|
30
|
-
var length = arguments.length;
|
|
31
|
-
var deep = false;
|
|
32
|
-
|
|
33
|
-
// Handle a deep copy situation
|
|
34
|
-
if (typeof target === 'boolean') {
|
|
35
|
-
deep = target;
|
|
36
|
-
target = arguments[1] || {};
|
|
37
|
-
// skip the boolean and the target
|
|
38
|
-
i = 2;
|
|
39
|
-
} else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) {
|
|
40
|
-
target = {};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
for (; i < length; ++i) {
|
|
44
|
-
options = arguments[i];
|
|
45
|
-
// Only deal with non-null/undefined values
|
|
46
|
-
if (options == null) continue;
|
|
47
|
-
|
|
48
|
-
// Extend the base object
|
|
49
|
-
for (name in options) {
|
|
50
|
-
if (name === '__proto__') continue;
|
|
51
|
-
|
|
52
|
-
src = target[name];
|
|
53
|
-
copy = options[name];
|
|
54
|
-
|
|
55
|
-
// Prevent never-ending loop
|
|
56
|
-
if (target === copy) continue;
|
|
57
|
-
|
|
58
|
-
// Recurse if we're merging plain objects
|
|
59
|
-
if (deep && copy && isPlainObject(copy)) {
|
|
60
|
-
clone = src && isPlainObject(src) ? src : {};
|
|
61
|
-
// Never move original objects, clone them
|
|
62
|
-
target[name] = extend(deep, clone, copy);
|
|
63
|
-
|
|
64
|
-
// Don't bring in undefined values
|
|
65
|
-
} else if (typeof copy !== 'undefined') {
|
|
66
|
-
target[name] = copy;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Return the modified object
|
|
72
|
-
return target;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
module.exports = {
|
|
76
|
-
extend,
|
|
77
|
-
isPlainObject,
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
4
|
+
const toStr = Object.prototype.toString;
|
|
5
|
+
|
|
6
|
+
function isPlainObject(obj) {
|
|
7
|
+
if (!obj || toStr.call(obj) !== '[object Object]') {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
|
|
12
|
+
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
|
|
13
|
+
// Not own constructor property must be Object
|
|
14
|
+
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Own properties are enumerated firstly, so to speed up,
|
|
19
|
+
// if last one is own, then all properties are own.
|
|
20
|
+
var key;
|
|
21
|
+
for (key in obj) { /**/ }
|
|
22
|
+
|
|
23
|
+
return typeof key === 'undefined' || hasOwn.call(obj, key);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function extend() {
|
|
27
|
+
var options, name, src, copy, clone;
|
|
28
|
+
var target = arguments[0];
|
|
29
|
+
var i = 1;
|
|
30
|
+
var length = arguments.length;
|
|
31
|
+
var deep = false;
|
|
32
|
+
|
|
33
|
+
// Handle a deep copy situation
|
|
34
|
+
if (typeof target === 'boolean') {
|
|
35
|
+
deep = target;
|
|
36
|
+
target = arguments[1] || {};
|
|
37
|
+
// skip the boolean and the target
|
|
38
|
+
i = 2;
|
|
39
|
+
} else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) {
|
|
40
|
+
target = {};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (; i < length; ++i) {
|
|
44
|
+
options = arguments[i];
|
|
45
|
+
// Only deal with non-null/undefined values
|
|
46
|
+
if (options == null) continue;
|
|
47
|
+
|
|
48
|
+
// Extend the base object
|
|
49
|
+
for (name in options) {
|
|
50
|
+
if (name === '__proto__') continue;
|
|
51
|
+
|
|
52
|
+
src = target[name];
|
|
53
|
+
copy = options[name];
|
|
54
|
+
|
|
55
|
+
// Prevent never-ending loop
|
|
56
|
+
if (target === copy) continue;
|
|
57
|
+
|
|
58
|
+
// Recurse if we're merging plain objects
|
|
59
|
+
if (deep && copy && isPlainObject(copy)) {
|
|
60
|
+
clone = src && isPlainObject(src) ? src : {};
|
|
61
|
+
// Never move original objects, clone them
|
|
62
|
+
target[name] = extend(deep, clone, copy);
|
|
63
|
+
|
|
64
|
+
// Don't bring in undefined values
|
|
65
|
+
} else if (typeof copy !== 'undefined') {
|
|
66
|
+
target[name] = copy;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Return the modified object
|
|
72
|
+
return target;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
module.exports = {
|
|
76
|
+
extend,
|
|
77
|
+
isPlainObject,
|
|
78
78
|
};
|
package/utils/helper.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export declare function fnDebounce(): (fn: any, delayTime: any, isImediate: any, args: any) => any;
|
|
2
|
-
export declare function getRandomString(): string;
|
|
3
|
-
export declare function mkdir(filepath: string, opt?: {}): void;
|
|
4
|
-
export declare function chmodPath(path: string, mode: number | string): void;
|
|
5
|
-
export declare function compareVersion(v1: string, v2: string): 0 | 1 | -1;
|
|
6
|
-
export declare function middleware(fn: Function): any;
|
|
7
|
-
export declare function stringify(obj: any, ignore?: any[]): string;
|
|
8
|
-
export declare function validValue(value: any): boolean;
|
|
9
|
-
export declare function checkConfig(prop: any): boolean;
|
|
10
|
-
export declare function loadConfig(prop: any): any;
|
|
11
|
-
export declare function sleep(ms: number): Promise<any>;
|
|
12
|
-
export declare function replaceArgsValue(argv: any, key: any, value: any): any;
|
|
13
|
-
export declare function getValueFromArgv(argv: any, key: any): any;
|
|
14
|
-
export declare function fileIsExist(filepath: string): boolean;
|
|
1
|
+
export declare function fnDebounce(): (fn: any, delayTime: any, isImediate: any, args: any) => any;
|
|
2
|
+
export declare function getRandomString(): string;
|
|
3
|
+
export declare function mkdir(filepath: string, opt?: {}): void;
|
|
4
|
+
export declare function chmodPath(path: string, mode: number | string): void;
|
|
5
|
+
export declare function compareVersion(v1: string, v2: string): 0 | 1 | -1;
|
|
6
|
+
export declare function middleware(fn: Function): any;
|
|
7
|
+
export declare function stringify(obj: any, ignore?: any[]): string;
|
|
8
|
+
export declare function validValue(value: any): boolean;
|
|
9
|
+
export declare function checkConfig(prop: any): boolean;
|
|
10
|
+
export declare function loadConfig(prop: any): any;
|
|
11
|
+
export declare function sleep(ms: number): Promise<any>;
|
|
12
|
+
export declare function replaceArgsValue(argv: any, key: any, value: any): any;
|
|
13
|
+
export declare function getValueFromArgv(argv: any, key: any): any;
|
|
14
|
+
export declare function fileIsExist(filepath: string): boolean;
|