fn

testUserAgentPlatform

v0.0.5

Tests navigator.platform against a regular expression, guarding for non-browser environments. Returns undefined when there is no navigator (e.g. during SSR) so callers can distinguish "no" from "unknown".

Example

ts
const onMac = testUserAgentPlatform(/^Mac/);

Signature

ts
declare function testUserAgentPlatform(re: RegExp): boolean | undefined;

Parameters

ParameterTypeDescription
reRegExpThe pattern to test navigator.platform against

Returns

boolean | undefinedThe match result, or undefined outside a browser