Skip to content

Commit

Permalink
refactor(yaml): use isObject() (#5822)
Browse files Browse the repository at this point in the history
  • Loading branch information
timreichen authored Aug 26, 2024
1 parent 3666d84 commit 37d3350
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions yaml/_dumper_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,12 +777,9 @@ export class DumperState {
block = this.flowLevel < 0 || this.flowLevel > level;
}

const objectOrArray = isObject(value) ||
Array.isArray(value);

let duplicateIndex = -1;
let duplicate = false;
if (objectOrArray) {
if (isObject(value)) {
duplicateIndex = this.duplicates.indexOf(value);
duplicate = duplicateIndex !== -1;
}
Expand All @@ -798,7 +795,7 @@ export class DumperState {
if (duplicate && this.usedDuplicates.has(value)) {
return `*ref_${duplicateIndex}`;
} else {
if (objectOrArray && duplicate) {
if (isObject(value) && duplicate) {
this.usedDuplicates.add(value);
}
if (isObject(value) && !Array.isArray(value)) {
Expand Down

0 comments on commit 37d3350

Please sign in to comment.