From 1420d29946b4a7ef6439a676880a0673483eb7f0 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 14 May 2018 11:50:59 +0200 Subject: [PATCH] module: introduce defaultModuleName in module.js This commit adds a constant named defaultModuleName to avoid duplicating it in the Module constructor function. --- lib/internal/vm/module.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/internal/vm/module.js b/lib/internal/vm/module.js index 5c8cc27c6042d8..a799cf2c3459b6 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); }