File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -629,6 +629,21 @@ logical processors available to the current Node.js instance.
629629console .log (` This process is running on ${ navigator .hardwareConcurrency } ` );
630630```
631631
632+ ### ` navigator.userAgent `
633+
634+ <!-- YAML
635+ added: REPLACEME
636+ -->
637+
638+ * {string}
639+
640+ The ` navigator.userAgent ` read-only property returns user agent
641+ consisting of the runtime name and the version.
642+
643+ ``` js
644+ console .log (` The user-agent is ${ navigator .userAgent } ` );
645+ ```
646+
632647## ` PerformanceEntry `
633648
634649<!-- YAML
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const kInitialize = Symbol('kInitialize');
2222class Navigator {
2323 // Private properties are used to avoid brand validations.
2424 #availableParallelism;
25+ #userAgent = `Node.js/${ process . version } ` ;
2526
2627 constructor ( ) {
2728 if ( arguments [ 0 ] === kInitialize ) {
@@ -37,10 +38,18 @@ class Navigator {
3738 this . #availableParallelism ??= getAvailableParallelism ( ) ;
3839 return this . #availableParallelism;
3940 }
41+
42+ /**
43+ * @return {string }
44+ */
45+ get userAgent ( ) {
46+ return this . #userAgent;
47+ }
4048}
4149
4250ObjectDefineProperties ( Navigator . prototype , {
4351 hardwareConcurrency : kEnumerableProperty ,
52+ userAgent : kEnumerableProperty ,
4453} ) ;
4554
4655module . exports = {
Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ const is = {
1313is . number ( + navigator . hardwareConcurrency , 'hardwareConcurrency' ) ;
1414is . number ( navigator . hardwareConcurrency , 'hardwareConcurrency' ) ;
1515assert . ok ( navigator . hardwareConcurrency > 0 ) ;
16+ assert . strictEqual ( typeof navigator . userAgent , 'string' ) ;
You can’t perform that action at this time.
0 commit comments