mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-07-08 01:31:00 +08:00
Config support jsonc
This commit is contained in:
11
config.ts
11
config.ts
@@ -1,7 +1,12 @@
|
||||
import { JsonValue, parse } from "std/jsonc/mod.ts";
|
||||
|
||||
export class Config {
|
||||
_data;
|
||||
constructor(data: { [x: string]: unknown }) {
|
||||
this._data = Object.assign({}, data);
|
||||
constructor(data: JsonValue) {
|
||||
this._data = <{ [x: string]: unknown }> <unknown> Object.assign(
|
||||
{},
|
||||
data,
|
||||
);
|
||||
}
|
||||
_return_string(key: string) {
|
||||
const v = this._data[key];
|
||||
@@ -58,5 +63,5 @@ export class Config {
|
||||
|
||||
export async function load_settings(path: string) {
|
||||
const s = (new TextDecoder()).decode(await Deno.readFile(path));
|
||||
return new Config(JSON.parse(s));
|
||||
return new Config(parse(s));
|
||||
}
|
||||
|
||||
3
deno.lock
generated
3
deno.lock
generated
@@ -6,6 +6,9 @@
|
||||
"https://deno.land/[email protected]/flags/mod.ts": "17f444ddbee43c5487568de0c6a076c7729cfe90d96d2ffcd2b8f8adadafb6e8",
|
||||
"https://deno.land/[email protected]/fmt/colors.ts": "d67e3cd9f472535241a8e410d33423980bec45047e343577554d3356e1f0ef4e",
|
||||
"https://deno.land/[email protected]/fs/exists.ts": "29c26bca8584a22876be7cb8844f1b6c8fc35e9af514576b78f5c6884d7ed02d",
|
||||
"https://deno.land/[email protected]/json/common.ts": "ecd5e87d45b5f0df33238ed8b1746e1444da7f5c86ae53d0f0b04280f41a25bb",
|
||||
"https://deno.land/[email protected]/jsonc/mod.ts": "b88dce28eb3645667caa856538ae2fe87af51410822544a0b45a4177ef3bd7dd",
|
||||
"https://deno.land/[email protected]/jsonc/parse.ts": "2910e33bc7c3b243e3b6f3a39ce4d6ca84337b277a8df6f2ad2d9e4adbcddc08",
|
||||
"https://deno.land/[email protected]/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0",
|
||||
"https://deno.land/[email protected]/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b",
|
||||
"https://deno.land/[email protected]/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0",
|
||||
|
||||
Reference in New Issue
Block a user