Skip to content

Commit

Permalink
Add Platform module for web target (#23387)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
EvanBacon authored and facebook-github-bot committed Feb 12, 2019
1 parent 344b32b commit daa79b0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Libraries/Utilities/Platform.web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/

'use strict';

export type PlatformSelectSpec<D, I> = {
default?: D,
web?: I,
};

const Platform = {
OS: 'web',
select: <D, I>(spec: PlatformSelectSpec<D, I>): D | I =>
'web' in spec ? spec.web : spec.default,
};

module.exports = Platform;

0 comments on commit daa79b0

Please sign in to comment.