|
3 | 3 | const assert = require('internal/assert');
|
4 | 4 | const {
|
5 | 5 | ArrayIsArray,
|
| 6 | + ArrayPrototypeForEach, |
| 7 | + ArrayPrototypeIndexOf, |
| 8 | + ArrayPrototypeSome, |
6 | 9 | ObjectCreate,
|
7 | 10 | ObjectDefineProperty,
|
8 | 11 | ObjectGetPrototypeOf,
|
9 | 12 | ObjectSetPrototypeOf,
|
10 |
| - SafePromise, |
| 13 | + PromiseAll, |
| 14 | + SafeWeakMap, |
11 | 15 | Symbol,
|
12 | 16 | TypeError,
|
13 |
| - WeakMap, |
14 | 17 | } = primordials;
|
15 | 18 |
|
16 | 19 | const { isContext } = internalBinding('contextify');
|
@@ -61,7 +64,7 @@ const STATUS_MAP = {
|
61 | 64 |
|
62 | 65 | let globalModuleId = 0;
|
63 | 66 | const defaultModuleName = 'vm:module';
|
64 |
| -const wrapToModuleMap = new WeakMap(); |
| 67 | +const wrapToModuleMap = new SafeWeakMap(); |
65 | 68 |
|
66 | 69 | const kWrap = Symbol('kWrap');
|
67 | 70 | const kContext = Symbol('kContext');
|
@@ -331,7 +334,7 @@ class SourceTextModule extends Module {
|
331 | 334 |
|
332 | 335 | try {
|
333 | 336 | if (promises !== undefined) {
|
334 |
| - await SafePromise.all(promises); |
| 337 | + await PromiseAll(promises); |
335 | 338 | }
|
336 | 339 | } catch (e) {
|
337 | 340 | this.#error = e;
|
@@ -391,13 +394,13 @@ class SourceTextModule extends Module {
|
391 | 394 | class SyntheticModule extends Module {
|
392 | 395 | constructor(exportNames, evaluateCallback, options = {}) {
|
393 | 396 | if (!ArrayIsArray(exportNames) ||
|
394 |
| - exportNames.some((e) => typeof e !== 'string')) { |
| 397 | + ArrayPrototypeSome(exportNames, (e) => typeof e !== 'string')) { |
395 | 398 | throw new ERR_INVALID_ARG_TYPE('exportNames',
|
396 | 399 | 'Array of unique strings',
|
397 | 400 | exportNames);
|
398 | 401 | } else {
|
399 |
| - exportNames.forEach((name, i) => { |
400 |
| - if (exportNames.indexOf(name, i + 1) !== -1) { |
| 402 | + ArrayPrototypeForEach(exportNames, (name, i) => { |
| 403 | + if (ArrayPrototypeIndexOf(exportNames, name, i + 1) !== -1) { |
401 | 404 | throw new ERR_INVALID_ARG_VALUE(`exportNames.${name}`,
|
402 | 405 | name,
|
403 | 406 | 'is duplicated');
|
|
0 commit comments