-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathnavigator.js
More file actions
44 lines (35 loc) · 814 Bytes
/
navigator.js
File metadata and controls
44 lines (35 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
const {
ObjectDefineProperties,
ReflectConstruct,
} = primordials;
const {
ERR_ILLEGAL_CONSTRUCTOR,
} = require('internal/errors').codes;
const {
kEnumerableProperty,
} = require('internal/util');
const {
getAvailableParallelism,
} = internalBinding('os');
class Navigator {
// Private properties are used to avoid brand validations.
#availableParallelism;
constructor() {
throw ERR_ILLEGAL_CONSTRUCTOR();
}
/**
* @return {number}
*/
get hardwareConcurrency() {
this.#availableParallelism ??= getAvailableParallelism();
return this.#availableParallelism;
}
}
ObjectDefineProperties(Navigator.prototype, {
hardwareConcurrency: kEnumerableProperty,
});
module.exports = {
navigator: ReflectConstruct(function() {}, [], Navigator),
Navigator,
};