MCPcopy Create free account
hub / github.com/denoland/std / #printAsInlineValue

Method #printAsInlineValue

toml/stringify.ts:135–162  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

133 return onlyPrimitive ? "ONLY_PRIMITIVE" : "ONLY_OBJECT_EXCLUDING_ARRAY";
134 }
135 #printAsInlineValue(value: unknown): string | number {
136 if (value instanceof Date) {
137 return `"${this.#printDate(value)}"`;
138 } else if (typeof value === "string" || value instanceof RegExp) {
139 return JSON.stringify(value.toString());
140 } else if (typeof value === "number") {
141 return value;
142 } else if (typeof value === "boolean") {
143 return value.toString();
144 } else if (
145 value instanceof Array
146 ) {
147 const str = value.map((x) => this.#printAsInlineValue(x)).join(",");
148 return `[${str}]`;
149 } else if (typeof value === "object") {
150 if (!value) {
151 throw new Error("Should never reach");
152 }
153 const str = Object.keys(value).map((key) => {
154 return `${joinKeys([key])} = ${
155 // deno-lint-ignore no-explicit-any
156 this.#printAsInlineValue((value as any)[key])}`;
157 }).join(",");
158 return `{${str}}`;
159 }
160
161 throw new Error("Should never reach");
162 }
163 #isSimplySerializable(value: unknown): boolean {
164 return (
165 typeof value === "string" ||

Callers 1

#printObjectMethod · 0.95

Calls 5

#printDateMethod · 0.95
joinKeysFunction · 0.85
stringifyMethod · 0.80
keysMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected