mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
Port host package to TypeScript
This commit is contained in:
1 parent
880fc77b88
commit
946c6e93c4
20 files changed
+811
-658
No files matched your search
@@ -439,17 +439,18 @@ export class InstanceConfig extends classes.Config {
|
||||
get(name: "factorio.rcon_port"): number | null;
|
||||
get(name: "factorio.rcon_password"): string | null;
|
||||
get(name: "factorio.player_online_autosave_slots"): number;
|
||||
get(name: "factorio.mod_pack"): string | null;
|
||||
get(name: "factorio.mod_pack"): number | null;
|
||||
get(name: "factorio.enable_save_patching"): boolean;
|
||||
get(name: "factorio.enable_whitelist"): boolean;
|
||||
get(name: "factorio.enable_authserver_bans"): boolean;
|
||||
get(name: "factorio.settings"): Object;
|
||||
get(name: "factorio.settings"): Record<string, unknown>;
|
||||
get(name: "factorio.verbose_logging"): boolean;
|
||||
get(name: "factorio.strip_paths"): boolean;
|
||||
get(name: "factorio.sync_adminlist"): boolean;
|
||||
get(name: "factorio.sync_whitelist"): boolean;
|
||||
get(name: "factorio.sync_banlist"): boolean;
|
||||
get(name: "factorio.max_concurrent_commands"): number;
|
||||
get(name: string) {
|
||||
get(name: string) {
|
||||
return super.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1696,28 +1696,23 @@ exposition.contentType = "text/plain; version=0.0.4";
|
||||
export function serializeResult(
|
||||
result: CollectorResult,
|
||||
options: {
|
||||
addLabels?: string,
|
||||
addLabels?: Record<string, string>,
|
||||
metricName?: string,
|
||||
metricHelp?: string,
|
||||
} = {}
|
||||
) {
|
||||
let addLabels = null;
|
||||
let metricName = result.metric.name;
|
||||
let metricHelp = result.metric.help;
|
||||
for (let [name, value] of Object.entries(options)) {
|
||||
if (name === "addLabels") {
|
||||
addLabels = value;
|
||||
} else if (name === "metricName") {
|
||||
metricName = value;
|
||||
} else if (name === "metricHelp") {
|
||||
metricHelp = value;
|
||||
} else {
|
||||
throw new Error(`Unrecognized option '${name}'`);
|
||||
}
|
||||
let {
|
||||
addLabels,
|
||||
metricName = result.metric.name,
|
||||
metricHelp = result.metric.help,
|
||||
...rest
|
||||
} = options;
|
||||
for (let name of Object.keys(rest)) {
|
||||
throw new Error(`Unrecognized option '${name}'`);
|
||||
}
|
||||
|
||||
let samples: Map<string, Map<string, number>>;
|
||||
if (addLabels === null) {
|
||||
if (!addLabels) {
|
||||
samples = result.samples;
|
||||
addLabels = {};
|
||||
|
||||
|
||||
Reference in new issue
Block a user