fn
testUserAgentPlatform
v0.0.5Tests 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
| Parameter | Type | Description |
|---|---|---|
re | RegExp | The pattern to test navigator.platform against |
Returns
boolean | undefinedThe match result, or undefined outside a browser