mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
parent
df562b1d28
commit
6c684b8bc8
@ -744,8 +744,12 @@ export class DumperState {
|
||||
if (block) {
|
||||
block = this.flowLevel < 0 || this.flowLevel > level;
|
||||
}
|
||||
|
||||
if (isObject(value)) {
|
||||
if (typeof value === "string" || value instanceof String) {
|
||||
value = value instanceof String ? value.valueOf() : value;
|
||||
if (tag !== "?") {
|
||||
value = this.stringifyScalar(value as string, { level, isKey });
|
||||
}
|
||||
} else if (isObject(value)) {
|
||||
const duplicateIndex = this.duplicates.indexOf(value);
|
||||
const duplicate = duplicateIndex !== -1;
|
||||
|
||||
@ -789,10 +793,6 @@ export class DumperState {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (typeof value === "string") {
|
||||
if (tag !== "?") {
|
||||
value = this.stringifyScalar(value, { level, isKey });
|
||||
}
|
||||
} else {
|
||||
if (this.skipInvalid) return null;
|
||||
throw new TypeError(`Cannot stringify ${typeof value}`);
|
||||
|
@ -753,6 +753,7 @@ Oren: Ben-Kiki
|
||||
|
||||
Deno.test("stringify() handles string", () => {
|
||||
assertEquals(stringify("Hello World"), "Hello World\n");
|
||||
assertEquals(stringify(new String("Hello World")), "Hello World\n");
|
||||
});
|
||||
|
||||
Deno.test("stringify() uses quotes around deprecated boolean notations when `compatMode: true`", () => {
|
||||
|
Loading…
Reference in New Issue
Block a user