UNPKG

945 BPlain TextView Raw
1import { Platform as ReactNativePlatform, PlatformOSType } from 'react-native';
2
3import { isDOMAvailable } from './environment/browser';
4
5export type PlatformSelectOSType = PlatformOSType | 'native' | 'electron' | 'default';
6
7export type PlatformSelect = <T>(specifics: { [platform in PlatformSelectOSType]?: T }) => T;
8
9const Platform = {
10 /**
11 * Denotes the currently running platform.
12 * Can be one of ios, android, web.
13 */
14 OS: ReactNativePlatform.OS,
15 /**
16 * Returns the value with the matching platform.
17 * Object keys can be any of ios, android, native, web, default.
18 *
19 * @ios ios, native, default
20 * @android android, native, default
21 * @web web, default
22 */
23 select: ReactNativePlatform.select as PlatformSelect,
24 /**
25 * Denotes if the DOM API is available in the current environment.
26 * The DOM is not available in native React runtimes and Node.js.
27 */
28 isDOMAvailable,
29};
30
31export default Platform;