Skip to content

Commit bc4ea34

Browse files
use structuredClone
1 parent a4b5273 commit bc4ea34

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/appConfigurationImpl.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
334334
throw new InvalidOperationError(`Ambiguity occurs when constructing configuration object from key '${key}', value '${value}'. The key should not be part of another key.`);
335335
}
336336
// Deep copy object values to avoid mutating the original objects in #configMap via shared references.
337-
// Using JSON.parse(JSON.stringify(...)) instead of structuredClone for compatibility with Node.js < 17.
338-
current[lastSegment] = typeof value === "object" && value !== null ? JSON.parse(JSON.stringify(value)) : value;
337+
current[lastSegment] = typeof value === "object" && value !== null ? structuredClone(value) : value;
339338
}
340339
return data;
341340
}
@@ -494,10 +493,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
494493
// the configuration setting loaded by the later selector in the iteration order will override the one from the earlier selector.
495494
const loadedSettings: Map<string, ConfigurationSetting> = new Map<string, ConfigurationSetting>();
496495
// Deep copy selectors to avoid modification if current client fails.
497-
// Using JSON.parse(JSON.stringify(...)) instead of structuredClone for compatibility with Node.js < 17.
498-
const selectorsToUpdate: PagedSettingsWatcher[] = JSON.parse(
499-
JSON.stringify(selectors)
500-
);
496+
const selectorsToUpdate: PagedSettingsWatcher[] = structuredClone(selectors);
501497

502498
for (const selector of selectorsToUpdate) {
503499
let settings: ConfigurationSetting[] = [];

0 commit comments

Comments
 (0)