Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit c7a5a1f

Browse files
committed
Update getNativeSource() for latest Node master branch.
1 parent 8a3d1ce commit c7a5a1f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

esm.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,22 @@ if (typeof jest === "object" && jest !== null &&
5858
}
5959

6060
function getNativeSource(thePath) {
61-
let source
61+
let result
6262

6363
try {
64-
const { _source } = require("internal/bootstrap/loaders").NativeModule
64+
const { internalBinding } = require("internal/bootstrap/loaders")
65+
const natives = internalBinding("natives")
6566

66-
if (has(_source, thePath)) {
67-
source = _source[thePath]
67+
if (has(natives, thePath)) {
68+
result = natives[thePath]
6869
}
6970
} catch (e) {}
7071

71-
return typeof source === "string" ? source : ""
72+
if (typeof result === "string") {
73+
return result
74+
}
75+
76+
return ""
7277
}
7378

7479
function has(object, name) {

0 commit comments

Comments
 (0)