source: trip-planner-front/node_modules/@babel/core/src/transformation/util/clone-deep-browser.ts@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 500 bytes
Line 
1const serialized = "$$ babel internal serialized type" + Math.random();
2
3function serialize(key, value) {
4 if (typeof value !== "bigint") return value;
5 return {
6 [serialized]: "BigInt",
7 value: value.toString(),
8 };
9}
10
11function revive(key, value) {
12 if (!value || typeof value !== "object") return value;
13 if (value[serialized] !== "BigInt") return value;
14 return BigInt(value.value);
15}
16
17export default function (value) {
18 return JSON.parse(JSON.stringify(value, serialize), revive);
19}
Note: See TracBrowser for help on using the repository browser.