From 37d3350c90c8555c5233d9d206be0225669b1e69 Mon Sep 17 00:00:00 2001 From: Tim Reichen Date: Mon, 26 Aug 2024 09:39:57 +0200 Subject: [PATCH] refactor(yaml): use `isObject()` (#5822) --- yaml/_dumper_state.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/yaml/_dumper_state.ts b/yaml/_dumper_state.ts index 3e61513f7414..fe7c2fc98d1e 100644 --- a/yaml/_dumper_state.ts +++ b/yaml/_dumper_state.ts @@ -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; } @@ -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)) {