Skip to content

Commit

Permalink
Update getNativeSource() for latest Node master branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 16, 2019
1 parent 8a3d1ce commit c7a5a1f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,22 @@ if (typeof jest === "object" && jest !== null &&
}

function getNativeSource(thePath) {
let source
let result

try {
const { _source } = require("internal/bootstrap/loaders").NativeModule
const { internalBinding } = require("internal/bootstrap/loaders")
const natives = internalBinding("natives")

if (has(_source, thePath)) {
source = _source[thePath]
if (has(natives, thePath)) {
result = natives[thePath]
}
} catch (e) {}

return typeof source === "string" ? source : ""
if (typeof result === "string") {
return result
}

return ""
}

function has(object, name) {
Expand Down

0 comments on commit c7a5a1f

Please sign in to comment.