GeezerVison is showing github.com — lib: further simplify assertions in vm/module · nodejs/node@5dd9fb2
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/vm/module.js +6-10Lines changed: 6 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -const { fail } = require('internal/assert'); |
| 3 | +const assert = require('internal/assert'); |
4 | 4 | const { |
5 | 5 | ArrayIsArray, |
6 | 6 | ObjectCreate, |
@@ -60,11 +60,6 @@ const kContext = Symbol('kContext'); |
60 | 60 | const kPerContextModuleId = Symbol('kPerContextModuleId'); |
61 | 61 | const kLink = Symbol('kLink'); |
62 | 62 |
|
63 | | -function failIfDebug() { |
64 | | - if (process.features.debug === false) return; |
65 | | - fail('VM Modules'); |
66 | | -} |
67 | | - |
68 | 63 | class Module { |
69 | 64 | constructor(options) { |
70 | 65 | emitExperimentalWarning('VM Modules'); |
@@ -120,12 +115,11 @@ class Module { |
120 | 115 | importModuleDynamicallyWrap(options.importModuleDynamically) : |
121 | 116 | undefined, |
122 | 117 | }); |
123 | | - } else if (syntheticEvaluationSteps) { |
| 118 | + } else { |
| 119 | + assert(syntheticEvaluationSteps); |
124 | 120 | this[kWrap] = new ModuleWrap(identifier, context, |
125 | 121 | syntheticExportNames, |
126 | 122 | syntheticEvaluationSteps); |
127 | | - } else { |
128 | | - failIfDebug(); |
129 | 123 | } |
130 | 124 |
|
131 | 125 | wrapToModuleMap.set(this[kWrap], this); |
@@ -381,7 +375,9 @@ class SyntheticModule extends Module { |
381 | 375 | identifier, |
382 | 376 | }); |
383 | 377 |
|
384 | | - this[kLink] = () => this[kWrap].link(() => { failIfDebug(); }); |
| 378 | + this[kLink] = () => this[kWrap].link(() => { |
| 379 | + assert.fail('link callback should not be called'); |
| 380 | + }); |
385 | 381 | } |
386 | 382 |
|
387 | 383 | setExport(name, value) { |
|