File tree 3 files changed +26
-0
lines changed
3 files changed +26
-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.
629
629
console .log (` This process is running on ${ navigator .hardwareConcurrency } ` );
630
630
```
631
631
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
+
632
647
## ` PerformanceEntry `
633
648
634
649
<!-- YAML
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const kInitialize = Symbol('kInitialize');
22
22
class Navigator {
23
23
// Private properties are used to avoid brand validations.
24
24
#availableParallelism;
25
+ #userAgent = `Node.js/${ process . versions . node } ` ;
25
26
26
27
constructor ( ) {
27
28
if ( arguments [ 0 ] === kInitialize ) {
@@ -37,10 +38,18 @@ class Navigator {
37
38
this . #availableParallelism ??= getAvailableParallelism ( ) ;
38
39
return this . #availableParallelism;
39
40
}
41
+
42
+ /**
43
+ * @return {string }
44
+ */
45
+ get userAgent ( ) {
46
+ return this . #userAgent;
47
+ }
40
48
}
41
49
42
50
ObjectDefineProperties ( Navigator . prototype , {
43
51
hardwareConcurrency : kEnumerableProperty ,
52
+ userAgent : kEnumerableProperty ,
44
53
} ) ;
45
54
46
55
module . exports = {
Original file line number Diff line number Diff line change @@ -13,3 +13,5 @@ const is = {
13
13
is . number ( + navigator . hardwareConcurrency , 'hardwareConcurrency' ) ;
14
14
is . number ( navigator . hardwareConcurrency , 'hardwareConcurrency' ) ;
15
15
assert . ok ( navigator . hardwareConcurrency > 0 ) ;
16
+ assert . strictEqual ( typeof navigator . userAgent , 'string' ) ;
17
+ assert . match ( navigator . userAgent , / ^ N o d e .j s \/ \d + \. \d + \. \d + ( - p r e ) ? $ / ) ;
You can’t perform that action at this time.
0 commit comments