@nsnanocat/util 1.9.6 → 2.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/getStorage.mjs +2 -16
- package/index.js +1 -0
- package/lib/argument.mjs +24 -0
- package/lib/index.js +1 -0
- package/package.json +42 -40
package/getStorage.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./lib/argument.mjs";
|
|
1
2
|
import { Console } from "./polyfill/Console.mjs";
|
|
2
3
|
import { Lodash as _ } from "./polyfill/Lodash.mjs";
|
|
3
4
|
import { Storage } from "./polyfill/Storage.mjs";
|
|
@@ -18,21 +19,6 @@ export function getStorage(key, names, database) {
|
|
|
18
19
|
/***************** Default *****************/
|
|
19
20
|
const Store = { Settings: database?.Default?.Settings || {}, Configs: database?.Default?.Configs || {}, Caches: {} };
|
|
20
21
|
Console.debug("Default", `Store.Settings类型: ${typeof Store.Settings}`, `Store.Settings: ${JSON.stringify(Store.Settings)}`);
|
|
21
|
-
/***************** Argument *****************/
|
|
22
|
-
Console.debug(`☑️ $argument`);
|
|
23
|
-
const argument = {};
|
|
24
|
-
switch (typeof $argument) {
|
|
25
|
-
// biome-ignore lint/suspicious/noFallthroughSwitchClause: <explanation>
|
|
26
|
-
case "string":
|
|
27
|
-
$argument = Object.fromEntries($argument.split("&").map(item => item.split("=", 2).map(i => i.replace(/\"/g, ""))));
|
|
28
|
-
case "object":
|
|
29
|
-
Object.keys($argument).forEach(key => _.set(argument, key, $argument[key]));
|
|
30
|
-
break;
|
|
31
|
-
case "undefined":
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
if (argument.LogLevel) Console.logLevel = argument.LogLevel;
|
|
35
|
-
Console.debug(`✅ $argument`, `argument: ${JSON.stringify(argument)}`);
|
|
36
22
|
/***************** BoxJs *****************/
|
|
37
23
|
// 包装为局部变量,用完释放内存
|
|
38
24
|
// BoxJs的清空操作返回假值空字符串, 逻辑或操作符会在左侧操作数为假值时返回右侧操作数。
|
|
@@ -56,7 +42,7 @@ export function getStorage(key, names, database) {
|
|
|
56
42
|
_.merge(Store.Configs, database?.[name]?.Configs);
|
|
57
43
|
_.merge(Store.Caches, BoxJs?.[name]?.Caches);
|
|
58
44
|
});
|
|
59
|
-
_.merge(Store.Settings, argument);
|
|
45
|
+
_.merge(Store.Settings, $argument);
|
|
60
46
|
if (Store.Settings.LogLevel) Console.logLevel = Store.Settings.LogLevel;
|
|
61
47
|
Console.debug("✅ Merge", `Store.Settings类型: ${typeof Store.Settings}`, `Store.Settings: ${JSON.stringify(Store.Settings)}`);
|
|
62
48
|
/***************** traverseObject *****************/
|
package/index.js
CHANGED
package/lib/argument.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Console } from "../polyfill/Console.mjs";
|
|
2
|
+
import { Lodash as _ } from "../polyfill/Lodash.mjs";
|
|
3
|
+
|
|
4
|
+
(() => {
|
|
5
|
+
Console.debug("☑️ $argument");
|
|
6
|
+
switch (typeof $argument) {
|
|
7
|
+
case "string": {
|
|
8
|
+
const argument = Object.fromEntries($argument.split("&").map(item => item.split("=", 2).map(i => i.replace(/\"/g, ""))));
|
|
9
|
+
$argument = {};
|
|
10
|
+
Object.keys(argument).forEach(key => _.set($argument, key, argument[key]));
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
case "object": {
|
|
14
|
+
const argument = {};
|
|
15
|
+
Object.keys($argument).forEach(key => _.set(argument, key, $argument[key]));
|
|
16
|
+
$argument = argument;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
case "undefined":
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
if ($argument.LogLevel) Console.logLevel = $argument.LogLevel;
|
|
23
|
+
Console.debug("✅ $argument", `$argument: ${JSON.stringify($argument)}`);
|
|
24
|
+
})();
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
2
|
+
"name": "@nsnanocat/util",
|
|
3
|
+
"description": "Pure JS's util module for well-known iOS network tools",
|
|
4
|
+
"author": "VirgilClyne <Virgil@nanocat.me>",
|
|
5
|
+
"homepage": "https://NSNanoCat.github.io/util",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"loon",
|
|
8
|
+
"quantumult",
|
|
9
|
+
"surge",
|
|
10
|
+
"shadowrocket",
|
|
11
|
+
"stash",
|
|
12
|
+
"egern"
|
|
13
|
+
],
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"bugs": "https://github.com/NSNanoCat/util/issues",
|
|
16
|
+
"main": "index.js",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"tsc:build": "npx tsc",
|
|
20
|
+
"test": "node --test test/*.test.js",
|
|
21
|
+
"test:merge": "node --test test/Lodash.merge.test.js",
|
|
22
|
+
"test:argument": "node --test test/argument.test.js",
|
|
23
|
+
"deprecate": "npm deprecate -f '@nsnanocat/util@0.0.0-preview' \"this package has been deprecated\""
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/NSNanoCat/util.git"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"index.js",
|
|
31
|
+
"lib",
|
|
32
|
+
"polyfill",
|
|
33
|
+
"getStorage.mjs"
|
|
34
|
+
],
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"typescript": "^5.6.3"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"registry": "https://registry.npmjs.org/",
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"version": "2.1.0"
|
|
43
|
+
}
|