| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,15 +44,18 @@ | |||
| 44 | 44 | /* global process, getLinkedBinding, getInternalBinding, primordials */ | |
| 45 | 45 | ||
| 46 | 46 | const { | |
| 47 | + ArrayPrototypeMap, | ||
| 48 | + ArrayPrototypePush, | ||
| 47 | 49 | Error, | |
| 48 | - Map, | ||
| 49 | 50 | ObjectCreate, | |
| 50 | 51 | ObjectDefineProperty, | |
| 51 | 52 | ObjectKeys, | |
| 52 | 53 | ObjectPrototypeHasOwnProperty, | |
| 53 | 54 | ReflectGet, | |
| 55 | + SafeMap, | ||
| 54 | 56 | SafeSet, | |
| 55 | 57 | String, | |
| 58 | + StringPrototypeStartsWith, | ||
| 56 | 59 | TypeError, | |
| 57 | 60 | } = primordials; | |
| 58 | 61 | ||
@@ -135,7 +138,7 @@ let internalBinding; | |||
| 135 | 138 | let mod = bindingObj[module]; | |
| 136 | 139 | if (typeof mod !== 'object') { | |
| 137 | 140 | mod = bindingObj[module] = getInternalBinding(module); | |
| 138 | - moduleLoadList.push(`Internal Binding ${module}`); | ||
| 141 | + ArrayPrototypePush(moduleLoadList, `Internal Binding ${module}`); | ||
| 139 | 142 | } | |
| 140 | 143 | return mod; | |
| 141 | 144 | }; | |
@@ -163,12 +166,14 @@ class NativeModule { | |||
| 163 | 166 | * A map from the module IDs to the module instances. | |
| 164 | 167 | * @type {Map<string, NativeModule>} | |
| 165 | 168 | */ | |
| 166 | - static map = new Map(moduleIds.map((id) => [id, new NativeModule(id)])); | ||
| 169 | + static map = new SafeMap( | ||
| 170 | + ArrayPrototypeMap(moduleIds, (id) => [id, new NativeModule(id)]) | ||
| 171 | + ); | ||
| 167 | 172 | ||
| 168 | 173 | constructor(id) { | |
| 169 | 174 | this.filename = `${id}.js`; | |
| 170 | 175 | this.id = id; | |
| 171 | - this.canBeRequiredByUsers = !id.startsWith('internal/'); | ||
| 176 | + this.canBeRequiredByUsers = !StringPrototypeStartsWith(id, 'internal/'); | ||
| 172 | 177 | ||
| 173 | 178 | // The CJS exports object of the module. | |
| 174 | 179 | this.exports = {}; | |
@@ -221,7 +226,7 @@ class NativeModule { | |||
| 221 | 226 | if (!this.exportKeys) { | |
| 222 | 227 | // When using --expose-internals, we do not want to reflect the named | |
| 223 | 228 | // exports from core modules as this can trigger unnecessary getters. | |
| 224 | - const internal = this.id.startsWith('internal/'); | ||
| 229 | + const internal = StringPrototypeStartsWith(this.id, 'internal/'); | ||
| 225 | 230 | this.exportKeys = internal ? [] : ObjectKeys(this.exports); | |
| 226 | 231 | } | |
| 227 | 232 | this.getESMFacade(); | |
@@ -271,7 +276,7 @@ class NativeModule { | |||
| 271 | 276 | this.loading = true; | |
| 272 | 277 | ||
| 273 | 278 | try { | |
| 274 | - const requireFn = this.id.startsWith('internal/deps/') ? | ||
| 279 | + const requireFn = StringPrototypeStartsWith(this.id, 'internal/deps/') ? | ||
| 275 | 280 | requireWithFallbackInDeps : nativeModuleRequire; | |
| 276 | 281 | ||
| 277 | 282 | const fn = compileFunction(id); | |
@@ -282,7 +287,7 @@ class NativeModule { | |||
| 282 | 287 | this.loading = false; | |
| 283 | 288 | } | |
| 284 | 289 | ||
| 285 | - moduleLoadList.push(`NativeModule ${id}`); | ||
| 290 | + ArrayPrototypePush(moduleLoadList, `NativeModule ${id}`); | ||
| 286 | 291 | return this.exports; | |
| 287 | 292 | } | |
| 288 | 293 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,6 +39,7 @@ | |||
| 39 | 39 | setupPrepareStackTrace(); | |
| 40 | 40 | ||
| 41 | 41 | const { | |
| 42 | + FunctionPrototypeCall, | ||
| 42 | 43 | JSONParse, | |
| 43 | 44 | ObjectDefineProperty, | |
| 44 | 45 | ObjectGetPrototypeOf, | |
@@ -299,7 +300,7 @@ function setupProcessObject() { | |||
| 299 | 300 | const EventEmitter = require('events'); | |
| 300 | 301 | const origProcProto = ObjectGetPrototypeOf(process); | |
| 301 | 302 | ObjectSetPrototypeOf(origProcProto, EventEmitter.prototype); | |
| 302 | - EventEmitter.call(process); | ||
| 303 | + FunctionPrototypeCall(EventEmitter, process); | ||
| 303 | 304 | ObjectDefineProperty(process, SymbolToStringTag, { | |
| 304 | 305 | enumerable: false, | |
| 305 | 306 | writable: true, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,11 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | - Map, | ||
| 5 | 4 | NumberParseInt, | |
| 6 | 5 | ObjectDefineProperty, | |
| 6 | + SafeMap, | ||
| 7 | 7 | SafeWeakMap, | |
| 8 | + StringPrototypeStartsWith, | ||
| 8 | 9 | } = primordials; | |
| 9 | 10 | ||
| 10 | 11 | const { | |
@@ -96,7 +97,8 @@ function patchProcessObject(expandArgv1) { | |||
| 96 | 97 | }); | |
| 97 | 98 | process.argv[0] = process.execPath; | |
| 98 | 99 | ||
| 99 | - if (expandArgv1 && process.argv[1] && !process.argv[1].startsWith('-')) { | ||
| 100 | + if (expandArgv1 && process.argv[1] && | ||
| 101 | + !StringPrototypeStartsWith(process.argv[1], '-')) { | ||
| 100 | 102 | // Expand process.argv[1] into a full path. | |
| 101 | 103 | const path = require('path'); | |
| 102 | 104 | try { | |
@@ -357,7 +359,7 @@ function initializePolicy() { | |||
| 357 | 359 | if (experimentalPolicy) { | |
| 358 | 360 | process.emitWarning('Policies are experimental.', | |
| 359 | 361 | 'ExperimentalWarning'); | |
| 360 | - const { pathToFileURL, URL } = require('url'); | ||
| 362 | + const { pathToFileURL, URL } = require('internal/url'); | ||
| 361 | 363 | // URL here as it is slightly different parsing | |
| 362 | 364 | // no bare specifiers for now | |
| 363 | 365 | let manifestURL; | |
@@ -374,7 +376,7 @@ function initializePolicy() { | |||
| 374 | 376 | if (experimentalPolicyIntegrity) { | |
| 375 | 377 | const SRI = require('internal/policy/sri'); | |
| 376 | 378 | const { createHash, timingSafeEqual } = require('crypto'); | |
| 377 | - const realIntegrities = new Map(); | ||
| 379 | + const realIntegrities = new SafeMap(); | ||
| 378 | 380 | const integrityEntries = SRI.parse(experimentalPolicyIntegrity); | |
| 379 | 381 | let foundMatch = false; | |
| 380 | 382 | for (let i = 0; i < integrityEntries.length; i++) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments