(exportNames, evaluateCallback, options = kEmptyObject)
| 460 | |
| 461 | class SyntheticModule extends Module { |
| 462 | constructor(exportNames, evaluateCallback, options = kEmptyObject) { |
| 463 | if (!ArrayIsArray(exportNames) || |
| 464 | ArrayPrototypeSome(exportNames, (e) => typeof e !== 'string')) { |
| 465 | throw new ERR_INVALID_ARG_TYPE('exportNames', |
| 466 | 'Array of unique strings', |
| 467 | exportNames); |
| 468 | } else { |
| 469 | ArrayPrototypeForEach(exportNames, (name, i) => { |
| 470 | if (ArrayPrototypeIndexOf(exportNames, name, i + 1) !== -1) { |
| 471 | throw new ERR_INVALID_ARG_VALUE(`exportNames.${name}`, |
| 472 | name, |
| 473 | 'is duplicated'); |
| 474 | } |
| 475 | }); |
| 476 | } |
| 477 | validateFunction(evaluateCallback, 'evaluateCallback'); |
| 478 | |
| 479 | validateObject(options, 'options'); |
| 480 | |
| 481 | const { context, identifier } = options; |
| 482 | |
| 483 | super({ |
| 484 | syntheticExportNames: exportNames, |
| 485 | syntheticEvaluationSteps: evaluateCallback, |
| 486 | context, |
| 487 | identifier, |
| 488 | }); |
| 489 | // A synthetic module does not have dependencies. |
| 490 | this[kWrap].instantiate(); |
| 491 | } |
| 492 | |
| 493 | link() { |
| 494 | validateThisInternalField(this, kWrap, 'SyntheticModule'); |
nothing calls this directly
no test coverage detected