forked from pinpoint-apm/pinpoint-node-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv8-compatibility.js
42 lines (35 loc) · 843 Bytes
/
v8-compatibility.js
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
/**
* Pinpoint Node.js Agent
* Copyright 2020-present NAVER Corp.
* Apache License v2.0
*/
const semver = require('semver')
class V8Compatibility {
constructor() {
this.initialize()
}
initialize() {
const nodeVersion = this.getNodeVersion()
if (!semver.satisfies(nodeVersion, '>=9.0.0')) {
try {
new ArrayBuffer()
this.disableModule = false
} catch (error) {
this.disableModule = true
}
} else {
this.disableModule = false
}
}
disabled() {
return this.disableModule
}
enabled() {
return !this.disabled()
}
getNodeVersion() {
return process.versions.node
}
}
const compatibility = new V8Compatibility()
module.exports = compatibility