From c7a5a1fec1e71f1dd64ccc6a19a14c358e424fd5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 15 Jan 2019 23:11:42 -0800 Subject: [PATCH] Update getNativeSource() for latest Node master branch. --- esm.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/esm.js b/esm.js index b5fa3534b..a005659a7 100644 --- a/esm.js +++ b/esm.js @@ -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) {