-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove some
lodash/cloneDeep
calls (#13032)
- Loading branch information
1 parent
0233e3c
commit 73dcd06
Showing
9 changed files
with
35 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/babel-core/src/transformation/util/clone-deep-browser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const serialized = "$$ babel internal serialized type" + Math.random(); | ||
|
||
function serialize(key, value) { | ||
if (typeof value !== "bigint") return value; | ||
return { | ||
[serialized]: "BigInt", | ||
value: value.toString(), | ||
}; | ||
} | ||
|
||
function revive(key, value) { | ||
if (!value || typeof value !== "object") return value; | ||
if (value[serialized] !== "BigInt") return value; | ||
return BigInt(value.value); | ||
} | ||
|
||
export default function (value) { | ||
return JSON.parse(JSON.stringify(value, serialize), revive); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import v8 from "v8"; | ||
import cloneDeep from "./clone-deep-browser"; | ||
|
||
export default function (value) { | ||
if (v8.deserialize && v8.serialize) { | ||
return v8.deserialize(v8.serialize(value)); | ||
} | ||
return cloneDeep(value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters