mm_config 2.2.0 → 2.2.2
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/index.js +9 -9
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -117,7 +117,7 @@ Config.prototype.saveAsync = async function () {
|
|
|
117
117
|
* @returns {Proxy} 配置对象的代理实例
|
|
118
118
|
*/
|
|
119
119
|
Config.prototype.getProxy = function () {
|
|
120
|
-
|
|
120
|
+
let self = this;
|
|
121
121
|
|
|
122
122
|
return new Proxy(this.options, {
|
|
123
123
|
set(obj, prop, val) {
|
|
@@ -161,7 +161,7 @@ Config.prototype.getProxy = function () {
|
|
|
161
161
|
* @returns {Proxy} 异步配置对象的代理实例
|
|
162
162
|
*/
|
|
163
163
|
Config.prototype.getAsyncProxy = function () {
|
|
164
|
-
|
|
164
|
+
let self = this;
|
|
165
165
|
|
|
166
166
|
return new Proxy(this.options, {
|
|
167
167
|
set(obj, prop, val) {
|
|
@@ -263,7 +263,7 @@ Config.prototype.keys = async function () {
|
|
|
263
263
|
if (this._conn) {
|
|
264
264
|
keys = await this._conn.keys();
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
let local_keys = Object.keys(this.options);
|
|
267
267
|
keys = keys.concat(local_keys);
|
|
268
268
|
return keys;
|
|
269
269
|
};
|
|
@@ -286,12 +286,12 @@ Config.prototype.destroy = function () {
|
|
|
286
286
|
* @returns {Proxy} 配置代理对象
|
|
287
287
|
*/
|
|
288
288
|
function create(file, options = {}, config = {}) {
|
|
289
|
-
|
|
289
|
+
let f = file.fullname();
|
|
290
290
|
// 检查是否已存在配置
|
|
291
291
|
if (dict[f]) {
|
|
292
292
|
return dict[f].getProxy();
|
|
293
293
|
}
|
|
294
|
-
|
|
294
|
+
let cfg = new Config({ file: f, ...config }, options);
|
|
295
295
|
cfg.saveSync(); // 确保文件存在
|
|
296
296
|
// 注册配置字典
|
|
297
297
|
dict[f] = cfg;
|
|
@@ -306,12 +306,12 @@ function create(file, options = {}, config = {}) {
|
|
|
306
306
|
* @returns {Promise<Proxy>} 异步配置代理对象
|
|
307
307
|
*/
|
|
308
308
|
async function createAsync(file, options = {}, config = {}) {
|
|
309
|
-
|
|
309
|
+
let f = file.fullname();
|
|
310
310
|
// 检查是否已存在配置
|
|
311
311
|
if (dict[f]) {
|
|
312
312
|
return dict[f].getAsyncProxy();
|
|
313
313
|
}
|
|
314
|
-
|
|
314
|
+
let cfg = new Config({ file: f, ...config }, options);
|
|
315
315
|
await cfg.saveAsync(); // 确保文件存在
|
|
316
316
|
// 注册配置字典
|
|
317
317
|
dict[f] = cfg;
|
|
@@ -325,7 +325,7 @@ async function createAsync(file, options = {}, config = {}) {
|
|
|
325
325
|
*/
|
|
326
326
|
function clear(file) {
|
|
327
327
|
if (!file) return clearAll();
|
|
328
|
-
|
|
328
|
+
let f = file.fullname();
|
|
329
329
|
if (dict[f]) {
|
|
330
330
|
delete dict[f];
|
|
331
331
|
}
|
|
@@ -348,7 +348,7 @@ function clearAll() {
|
|
|
348
348
|
* @returns {Proxy} 配置代理对象
|
|
349
349
|
*/
|
|
350
350
|
function conf(options, file, config = {}) {
|
|
351
|
-
return
|
|
351
|
+
return create(file, options, config);
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
// 模块导出
|