UNPKG

835 BJavaScriptView Raw
1/**
2 * @internal Util used for exporting opposing platform utils and warning the user if they are trying to access them.
3 */
4export function platformCheck(parent) {
5 if (__DEV__) {
6 return new Proxy({}, {
7 get(_, prop) {
8 const propPretty = [parent, prop.toString()].join('.');
9 const hintPlatformCheck = __ANDROID__ ? '__IOS__' : '__ANDROID__';
10 // prettier-ignore
11 const errorMsg = [
12 `Trying to access "${propPretty}" without checking platform first.`,
13 `Hint: Use "${hintPlatformCheck}" to check platform before accessing "${propPretty}".`
14 ].join('\n');
15 throw new Error(errorMsg);
16 },
17 });
18 }
19 return undefined;
20}
21//# sourceMappingURL=platform-check.js.map
\No newline at end of file