You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-2
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
**Cross-Runtime Environment Detection for JavaScript and TypeScript**
6
6
7
-
This package provides a well defined, cross runtime, way to determine details about the current runtime environment (Deno, Bun, Node.js, or browser) along with detailed browser detection.
7
+
This package provides a well defined, cross runtime, way to determine details about the current runtime environment (Deno, Bun, Node.js, or browser) along with detailed browser detection. Since version `1.1.0`, it can also parse a User Agent string to extract OS, Product and Version in a reliable way.
8
8
9
9
Try it out at [https://jsfiddle.net/hexag0n/x9568nmy/](https://jsfiddle.net/hexag0n/x9568nmy/).
10
10
@@ -17,7 +17,7 @@ import {
17
17
CurrentProduct,
18
18
CurrentRuntime,
19
19
CurrentVersion,
20
-
Runtime
20
+
Runtime
21
21
} from"@cross/runtime";
22
22
23
23
console.log(`Runtime: ${CurrentRuntime}`);
@@ -45,6 +45,34 @@ Version: 1.0.30
45
45
You're not running Deno!
46
46
```
47
47
48
+
... and an example of parsing User Agent String:
49
+
50
+
```javascript
51
+
import {
52
+
getVersionFromUserAgent,
53
+
getProductFromUserAgent,
54
+
getOSFromUserAgent
55
+
} from"@cross/runtime";
56
+
57
+
constua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36";
0 commit comments