Skip to content

Commit 80931fb

Browse files
author
Brian Vaughn
committed
Renamed "safeSerialize" to "serializeToString" and added inline comment
1 parent 7589f9e commit 80931fb

File tree

1 file changed

+3
-2
lines changed
  • packages/react-devtools-shared/src/backend

1 file changed

+3
-2
lines changed

packages/react-devtools-shared/src/backend/utils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function cleanForBridge(
3939
}
4040

4141
export function copyToClipboard(value: any): void {
42-
const safeToCopy = safeSerialize(value);
42+
const safeToCopy = serializeToString(value);
4343
copy(safeToCopy === undefined ? 'undefined' : safeToCopy);
4444
}
4545

@@ -59,8 +59,9 @@ export function copyWithSet(
5959
return updated;
6060
}
6161

62-
export function safeSerialize(data: any): string {
62+
export function serializeToString(data: any): string {
6363
const cache = new Set();
64+
// Use a custom replacer function to protect against circular references.
6465
return JSON.stringify(data, (key, value) => {
6566
if (typeof value === 'object' && value !== null) {
6667
if (cache.has(value)) {

0 commit comments

Comments
 (0)