mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
fix(yaml): fix StringifyOptions.noRefs
(#5292)
This commit is contained in:
parent
484977ff9e
commit
ed1ab2684a
@ -928,7 +928,7 @@ function inspectNode(
|
||||
if (object !== null && typeof object === "object") {
|
||||
const index = objects.indexOf(object);
|
||||
if (index !== -1) {
|
||||
if (duplicatesIndexes.includes(index)) {
|
||||
if (!duplicatesIndexes.includes(index)) {
|
||||
duplicatesIndexes.push(index);
|
||||
}
|
||||
} else {
|
||||
|
@ -275,3 +275,18 @@ Deno.test({
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "stringify() works with noRefs option",
|
||||
fn() {
|
||||
const obj = { foo: "bar" };
|
||||
assertEquals(
|
||||
stringify([obj, obj], { noRefs: true }),
|
||||
`- foo: bar\n- foo: bar\n`,
|
||||
);
|
||||
assertEquals(
|
||||
stringify([obj, obj], { noRefs: false }),
|
||||
`- &ref_0\n foo: bar\n- *ref_0\n`,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user