Skip to content

Commit daa79b0

Browse files
EvanBaconfacebook-github-bot
authored andcommitted
Add Platform module for web target (#23387)
Summary: Added a Platform file for module for instances where internal modules need Platform. ex: https://github.com/facebook/react-native/blob/78be6efda97096e8388af5bf2dadb9c9de4fa0ba/Libraries/Utilities/Dimensions.js#L14 * Added `Libraries/Utilities/Platform.web.js` [CATEGORY] [TYPE] - Message Pull Request resolved: #23387 Differential Revision: D14041834 Pulled By: cpojer fbshipit-source-id: 9be7ad647d6a644956efa622b936fcecee7c1a1f
1 parent 344b32b commit daa79b0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Libraries/Utilities/Platform.web.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @flow
9+
*/
10+
11+
'use strict';
12+
13+
export type PlatformSelectSpec<D, I> = {
14+
default?: D,
15+
web?: I,
16+
};
17+
18+
const Platform = {
19+
OS: 'web',
20+
select: <D, I>(spec: PlatformSelectSpec<D, I>): D | I =>
21+
'web' in spec ? spec.web : spec.default,
22+
};
23+
24+
module.exports = Platform;

0 commit comments

Comments
 (0)