import {
normalizeOptionalLowercaseString,
normalizeOptionalString,
} from "../shared/string-coerce.js"; import type { CommandArgValues } from "./commands-registry.types.js";
export type CommandArgsFormatter = (values: CommandArgValues) => string | undefined;
function normalizeArgValue(value: unknown): string | undefined { if (value == null) { return undefined;
}
let text: string; if (typeof value === "string") {
text = normalizeOptionalString(value) ?? "";
} elseif (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
text = normalizeOptionalString(String(value)) ?? "";
} elseif (typeof value === "symbol") {
text = normalizeOptionalString(value.toString()) ?? "";
} elseif (typeof value === "function") {
text = normalizeOptionalString(value.toString()) ?? "";
} else { // Objects and arrays
text = JSON.stringify(value);
} return text ? text : undefined;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.