diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-05-14 11:50:59 +0200 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-05-16 07:47:24 +0200 |
commit | ea01d305f65147325866f68a93d511d076a82016 (patch) | |
tree | 875e90afd03794d67e14258cd1f6ebe88bfb6670 | |
parent | 2b8cd93246a87378167d7d25a7d90fabbd235590 (diff) | |
download | android-node-v8-ea01d305f65147325866f68a93d511d076a82016.tar.gz android-node-v8-ea01d305f65147325866f68a93d511d076a82016.tar.bz2 android-node-v8-ea01d305f65147325866f68a93d511d076a82016.zip |
module: introduce defaultModuleName in module.js
This commit adds a constant named defaultModuleName to avoid duplicating
it in the Module constructor function.
PR-URL: https://github.com/nodejs/node/pull/20709
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r-- | lib/internal/vm/module.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/internal/vm/module.js b/lib/internal/vm/module.js index 5c8cc27c60..a799cf2c34 100644 --- a/lib/internal/vm/module.js +++ b/lib/internal/vm/module.js @@ -48,6 +48,7 @@ const linkingStatusMap = new WeakMap(); const initImportMetaMap = new WeakMap(); // ModuleWrap -> vm.Module const wrapToModuleMap = new WeakMap(); +const defaultModuleName = 'vm:module'; class Module { constructor(src, options = {}) { @@ -82,13 +83,13 @@ class Module { } url = new URL(url).href; } else if (context === undefined) { - url = `vm:module(${globalModuleId++})`; + url = `${defaultModuleName}(${globalModuleId++})`; } else if (perContextModuleId.has(context)) { const curId = perContextModuleId.get(context); - url = `vm:module(${curId})`; + url = `${defaultModuleName}(${curId})`; perContextModuleId.set(context, curId + 1); } else { - url = 'vm:module(0)'; + url = `${defaultModuleName}(0)`; perContextModuleId.set(context, 1); } |