chore(nx-dev): use structuredClone for cloning objects (#14698)

This commit is contained in:
Benjamin Cabanes 2023-01-30 14:03:32 -05:00 committed by GitHub
parent d5c5952386
commit 5bd087f553
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 6 deletions

View File

@ -36,7 +36,7 @@ export class DocumentsApi {
throw new Error('public document sources cannot be undefined'); throw new Error('public document sources cannot be undefined');
} }
this.manifest = Object.assign({}, this.options.manifest); this.manifest = structuredClone(this.options.manifest);
} }
private getManifestKey(path: string): string { private getManifestKey(path: string): string {
return '/' + path; return '/' + path;

View File

@ -7,7 +7,7 @@ export class TagsApi {
throw new Error('tags property cannot be undefined'); throw new Error('tags property cannot be undefined');
} }
this.manifest = Object.assign({}, this.tags); this.manifest = structuredClone(this.tags);
} }
getAssociatedItems(tag: string): RelatedDocument[] { getAssociatedItems(tag: string): RelatedDocument[] {

View File

@ -38,7 +38,7 @@ export class PackagesApi {
throw new Error('public document sources cannot be undefined'); throw new Error('public document sources cannot be undefined');
} }
this.manifest = Object.assign({}, this.options.manifest); this.manifest = structuredClone(this.options.manifest);
} }
getFilePath(path: string): string { getFilePath(path: string): string {

View File

@ -466,7 +466,7 @@ function generateJsonExampleForHelper(
} }
if (matchedType === 'object') { if (matchedType === 'object') {
const example = Object.assign({}, ...examples); const example = structuredClone(examples);
return Example.of(example); return Example.of(example);
} else if ( } else if (
matchedType === 'string' || matchedType === 'string' ||

View File

@ -393,7 +393,7 @@ function documentRecurseOperations(
target: DocumentMetadata, target: DocumentMetadata,
parent: DocumentMetadata parent: DocumentMetadata
): DocumentMetadata { ): DocumentMetadata {
const document: DocumentMetadata = Object.assign({}, target); const document: DocumentMetadata = structuredClone(target);
/** /**
* Calculate `path` * Calculate `path`

View File

@ -72,7 +72,7 @@ export function schemaResolver(
resolveExamplesFile: () => void; resolveExamplesFile: () => void;
getSchema: () => NxSchema; getSchema: () => NxSchema;
} { } {
const updatedSchema: NxSchema = Object.assign({}, schema); const updatedSchema: NxSchema = structuredClone(schema);
return { return {
resolveReferences: () => { resolveReferences: () => {
traverseAndReplaceReferences(updatedSchema, '$ref', lookup); traverseAndReplaceReferences(updatedSchema, '$ref', lookup);