Clean up process globals

Summary: Cleaned up some `process` references

Reviewed By: passy

Differential Revision: D33184882

fbshipit-source-id: 6fc56bcea4e145ba97aa8bf9e689e53e2bf239cc
This commit is contained in:
Michel Weststrate
2021-12-17 14:11:20 -08:00
committed by Facebook GitHub Bot
parent e46fcba0b2
commit 4630f37786
6 changed files with 36 additions and 25 deletions

View File

@@ -7,6 +7,8 @@
* @format
*/
import {isProduction} from 'flipper-common';
/**
* makeShallowSerializable will prepare common data structures, like Map and Set, for JSON serialization.
* However, this will happen only for the root object and not recursively to keep things efficiently.
@@ -66,18 +68,12 @@ export function deserializeShallowObject(obj: any): any {
return obj;
}
// TODO: introduce a isProduction utility!
declare const process: any;
/**
* Asserts a value is JSON serializable.
* Will print a warning if a value is JSON serializable, but isn't a pure tree
*/
export function assertSerializable(obj: any) {
if (
typeof process === 'undefined' ||
(process.env.NODE_ENV !== 'test' && process.env.NODE_ENV !== 'development')
) {
if (isProduction()) {
return;
}
// path to current object