Skip to content

Commit 84b9c62

Browse files
committed
rename parsePlatformValue to tryParsePlatform
1 parent f4b7ce0 commit 84b9c62

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

packages/tools-react-native/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ import * as platformTools from "@rnx-kit/tools-react-native/platform";
3737
| platform | `getAvailablePlatformsUncached(startDir, platformMap)` | Returns a map of available React Native platforms. The result is NOT cached. |
3838
| platform | `getModuleSuffixes(platform, appendEmpty)` | Get the module suffixes array for a given platform, suitable for use with TypeScript's moduleSuffixes setting in the form of ['.ios', '.native', ''] or ['.windows', '.win', '.native', ''] or similar |
3939
| platform | `parsePlatform(val)` | Parse a string to ensure it maps to a valid react-native platform. |
40-
| platform | `parsePlatformValue(val)` | |
4140
| platform | `platformExtensions(platform)` | Returns file extensions that can be mapped to the target platform. |
4241
| platform | `platformValues()` | |
42+
| platform | `tryParsePlatform(val)` | |
4343

4444
<!-- @rnx-kit/api end -->

packages/tools-react-native/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export {
1515
getAvailablePlatformsUncached,
1616
getModuleSuffixes,
1717
parsePlatform,
18-
parsePlatformValue,
1918
platformExtensions,
2019
platformValues,
20+
tryParsePlatform,
2121
} from "./platform";
2222
export type { AllPlatforms } from "./platform";

packages/tools-react-native/src/platform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export function platformExtensions(platform: string): string[] {
172172
/**
173173
* @returns the given string as a platform value or undefined if it is not a valid platform.
174174
*/
175-
export function parsePlatformValue(val: string): AllPlatforms | undefined {
175+
export function tryParsePlatform(val: string): AllPlatforms | undefined {
176176
return allValues.includes(val as AllPlatforms)
177177
? (val as AllPlatforms)
178178
: undefined;
@@ -185,7 +185,7 @@ export function parsePlatformValue(val: string): AllPlatforms | undefined {
185185
* @returns React-native platform name. Throws `Error` on failure.
186186
*/
187187
export function parsePlatform(val: string): AllPlatforms {
188-
const platform = parsePlatformValue(val);
188+
const platform = tryParsePlatform(val);
189189
if (!platform) {
190190
throw new Error(`Unknown platform '${val}'`);
191191
}

0 commit comments

Comments
 (0)