Skip to content

Commit 1b502b5

Browse files
Copilothotlong
andcommitted
refactor: use structuredClone instead of JSON.parse(JSON.stringify()) for deep cloning
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent d62fbe4 commit 1b502b5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/metadata/src/metadata-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ export class MetadataManager implements IMetadataService {
411411
for (const item of packageItems) {
412412
const updated = {
413413
...item.data,
414-
publishedDefinition: JSON.parse(JSON.stringify(item.data.metadata ?? item.data)),
414+
publishedDefinition: structuredClone(item.data.metadata ?? item.data),
415415
publishedAt: now,
416416
publishedBy: publishedBy ?? item.data.publishedBy,
417417
version: newVersion,
@@ -458,7 +458,7 @@ export class MetadataManager implements IMetadataService {
458458
if (item.data.publishedDefinition !== undefined) {
459459
const reverted = {
460460
...item.data,
461-
metadata: JSON.parse(JSON.stringify(item.data.publishedDefinition)),
461+
metadata: structuredClone(item.data.publishedDefinition),
462462
state: 'active',
463463
};
464464
await this.register(item.type, item.name, reverted);

0 commit comments

Comments
 (0)