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