| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 69a8f05 commit 39d0ced
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,18 +6,21 @@ | |||
| 6 | 6 | ||
| 7 | 7 | const { | |
| 8 | 8 | ArrayIsArray, | |
| 9 | + ArrayPrototypeMap, | ||
| 10 | + ArrayPrototypePush, | ||
| 11 | + ArrayPrototypeSplice, | ||
| 9 | 12 | BigUint64Array, | |
| 10 | 13 | Float64Array, | |
| 11 | 14 | NumberMAX_SAFE_INTEGER, | |
| 12 | - ObjectDefineProperties, | ||
| 13 | 15 | ObjectDefineProperty, | |
| 14 | 16 | ObjectFreeze, | |
| 15 | - ObjectGetOwnPropertyDescriptors, | ||
| 17 | + ReflectApply, | ||
| 16 | 18 | RegExpPrototypeTest, | |
| 17 | - Set, | ||
| 18 | - SetPrototype, | ||
| 19 | - SetPrototypeHas, | ||
| 19 | + SafeSet, | ||
| 20 | + StringPrototypeEndsWith, | ||
| 20 | 21 | StringPrototypeReplace, | |
| 22 | + StringPrototypeSlice, | ||
| 23 | + StringPrototypeStartsWith, | ||
| 21 | 24 | Uint32Array, | |
| 22 | 25 | } = primordials; | |
| 23 | 26 | ||
@@ -94,7 +97,7 @@ function wrapProcessMethods(binding) { | |||
| 94 | 97 | } = binding; | |
| 95 | 98 | ||
| 96 | 99 | function _rawDebug(...args) { | |
| 97 | - binding._rawDebug(format.apply(null, args)); | ||
| 100 | + binding._rawDebug(ReflectApply(format, null, args)); | ||
| 98 | 101 | } | |
| 99 | 102 | ||
| 100 | 103 | // Create the argument array that will be passed to the native function. | |
@@ -256,31 +259,31 @@ function buildAllowedFlags() { | |||
| 256 | 259 | const allowedNodeEnvironmentFlags = []; | |
| 257 | 260 | for (const [name, info] of options) { | |
| 258 | 261 | if (info.envVarSettings === kAllowedInEnvironment) { | |
| 259 | - allowedNodeEnvironmentFlags.push(name); | ||
| 262 | + ArrayPrototypePush(allowedNodeEnvironmentFlags, name); | ||
| 260 | 263 | } | |
| 261 | 264 | } | |
| 262 | 265 | ||
| 263 | 266 | for (const [ from, expansion ] of aliases) { | |
| 264 | 267 | let isAccepted = true; | |
| 265 | 268 | for (const to of expansion) { | |
| 266 | - if (!to.startsWith('-') || to === '--') continue; | ||
| 269 | + if (!StringPrototypeStartsWith(to, '-') || to === '--') continue; | ||
| 267 | 270 | const recursiveExpansion = aliases.get(to); | |
| 268 | 271 | if (recursiveExpansion) { | |
| 269 | 272 | if (recursiveExpansion[0] === to) | |
| 270 | - recursiveExpansion.splice(0, 1); | ||
| 271 | - expansion.push(...recursiveExpansion); | ||
| 273 | + ArrayPrototypeSplice(recursiveExpansion, 0, 1); | ||
| 274 | + ArrayPrototypePush(expansion, ...recursiveExpansion); | ||
| 272 | 275 | continue; | |
| 273 | 276 | } | |
| 274 | 277 | isAccepted = options.get(to).envVarSettings === kAllowedInEnvironment; | |
| 275 | 278 | if (!isAccepted) break; | |
| 276 | 279 | } | |
| 277 | 280 | if (isAccepted) { | |
| 278 | 281 | let canonical = from; | |
| 279 | - if (canonical.endsWith('=')) | ||
| 280 | - canonical = canonical.substr(0, canonical.length - 1); | ||
| 281 | - if (canonical.endsWith(' <arg>')) | ||
| 282 | - canonical = canonical.substr(0, canonical.length - 4); | ||
| 283 | - allowedNodeEnvironmentFlags.push(canonical); | ||
| 282 | + if (StringPrototypeEndsWith(canonical, '=')) | ||
| 283 | + canonical = StringPrototypeSlice(canonical, 0, canonical.length - 1); | ||
| 284 | + if (StringPrototypeEndsWith(canonical, ' <arg>')) | ||
| 285 | + canonical = StringPrototypeSlice(canonical, 0, canonical.length - 4); | ||
| 286 | + ArrayPrototypePush(allowedNodeEnvironmentFlags, canonical); | ||
| 284 | 287 | } | |
| 285 | 288 | } | |
| 286 | 289 | ||
@@ -289,14 +292,10 @@ function buildAllowedFlags() { | |||
| 289 | 292 | ||
| 290 | 293 | // Save these for comparison against flags provided to | |
| 291 | 294 | // process.allowedNodeEnvironmentFlags.has() which lack leading dashes. | |
| 292 | - // Avoid interference w/ user code by flattening `Set.prototype` into | ||
| 293 | - // each object. | ||
| 294 | - const nodeFlags = ObjectDefineProperties( | ||
| 295 | - new Set(allowedNodeEnvironmentFlags.map(trimLeadingDashes)), | ||
| 296 | - ObjectGetOwnPropertyDescriptors(SetPrototype) | ||
| 297 | - ); | ||
| 298 | - | ||
| 299 | - class NodeEnvironmentFlagsSet extends Set { | ||
| 295 | + const nodeFlags = new SafeSet(ArrayPrototypeMap(allowedNodeEnvironmentFlags, | ||
| 296 | + trimLeadingDashes)); | ||
| 297 | + | ||
| 298 | + class NodeEnvironmentFlagsSet extends SafeSet { | ||
| 300 | 299 | constructor(...args) { | |
| 301 | 300 | super(...args); | |
| 302 | 301 | ||
@@ -328,9 +327,9 @@ function buildAllowedFlags() { | |||
| 328 | 327 | key = StringPrototypeReplace(key, replaceUnderscoresRegex, '-'); | |
| 329 | 328 | if (RegExpPrototypeTest(leadingDashesRegex, key)) { | |
| 330 | 329 | key = StringPrototypeReplace(key, trailingValuesRegex, ''); | |
| 331 | - return SetPrototypeHas(this, key); | ||
| 330 | + return super.has(key); | ||
| 332 | 331 | } | |
| 333 | - return SetPrototypeHas(nodeFlags, key); | ||
| 332 | + return nodeFlags.has(key); | ||
| 334 | 333 | } | |
| 335 | 334 | return false; | |
| 336 | 335 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,11 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | + ArrayPrototypePush, | ||
| 5 | + ArrayPrototypeShift, | ||
| 4 | 6 | Error, | |
| 5 | 7 | ObjectDefineProperty, | |
| 6 | - WeakMap, | ||
| 8 | + SafeWeakMap, | ||
| 7 | 9 | } = primordials; | |
| 8 | 10 | ||
| 9 | 11 | const { | |
@@ -25,7 +27,7 @@ const { | |||
| 25 | 27 | // *Must* match Environment::TickInfo::Fields in src/env.h. | |
| 26 | 28 | const kHasRejectionToWarn = 1; | |
| 27 | 29 | ||
| 28 | - const maybeUnhandledPromises = new WeakMap(); | ||
| 30 | + const maybeUnhandledPromises = new SafeWeakMap(); | ||
| 29 | 31 | const pendingUnhandledRejections = []; | |
| 30 | 32 | const asyncHandledRejections = []; | |
| 31 | 33 | let lastPromiseId = 0; | |
@@ -121,7 +123,7 @@ function unhandledRejection(promise, reason) { | |||
| 121 | 123 | domain: process.domain | |
| 122 | 124 | }); | |
| 123 | 125 | // This causes the promise to be referenced at least for one tick. | |
| 124 | - pendingUnhandledRejections.push(promise); | ||
| 126 | + ArrayPrototypePush(pendingUnhandledRejections, promise); | ||
| 125 | 127 | setHasRejectionToWarn(true); | |
| 126 | 128 | } | |
| 127 | 129 | ||
@@ -137,7 +139,7 @@ function handledRejection(promise) { | |||
| 137 | 139 | `asynchronously (rejection id: ${uid})`); | |
| 138 | 140 | warning.name = 'PromiseRejectionHandledWarning'; | |
| 139 | 141 | warning.id = uid; | |
| 140 | - asyncHandledRejections.push({ promise, warning }); | ||
| 142 | + ArrayPrototypePush(asyncHandledRejections, { promise, warning }); | ||
| 141 | 143 | setHasRejectionToWarn(true); | |
| 142 | 144 | return; | |
| 143 | 145 | } | |
@@ -178,15 +180,15 @@ function processPromiseRejections() { | |||
| 178 | 180 | let maybeScheduledTicksOrMicrotasks = asyncHandledRejections.length > 0; | |
| 179 | 181 | ||
| 180 | 182 | while (asyncHandledRejections.length > 0) { | |
| 181 | - const { promise, warning } = asyncHandledRejections.shift(); | ||
| 183 | + const { promise, warning } = ArrayPrototypeShift(asyncHandledRejections); | ||
| 182 | 184 | if (!process.emit('rejectionHandled', promise)) { | |
| 183 | 185 | process.emitWarning(warning); | |
| 184 | 186 | } | |
| 185 | 187 | } | |
| 186 | 188 | ||
| 187 | 189 | let len = pendingUnhandledRejections.length; | |
| 188 | 190 | while (len--) { | |
| 189 | - const promise = pendingUnhandledRejections.shift(); | ||
| 191 | + const promise = ArrayPrototypeShift(pendingUnhandledRejections); | ||
| 190 | 192 | const promiseInfo = maybeUnhandledPromises.get(promise); | |
| 191 | 193 | if (promiseInfo === undefined) { | |
| 192 | 194 | continue; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,8 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | - Map, | ||
| 4 | + FunctionPrototypeBind, | ||
| 5 | + SafeMap, | ||
| 5 | 6 | } = primordials; | |
| 6 | 7 | ||
| 7 | 8 | const { | |
@@ -11,7 +12,7 @@ const { | |||
| 11 | 12 | const { signals } = internalBinding('constants').os; | |
| 12 | 13 | ||
| 13 | 14 | let Signal; | |
| 14 | - const signalWraps = new Map(); | ||
| 15 | + const signalWraps = new SafeMap(); | ||
| 15 | 16 | ||
| 16 | 17 | function isSignal(event) { | |
| 17 | 18 | return typeof event === 'string' && signals[event] !== undefined; | |
@@ -26,7 +27,7 @@ function startListeningIfSignal(type) { | |||
| 26 | 27 | ||
| 27 | 28 | wrap.unref(); | |
| 28 | 29 | ||
| 29 | - wrap.onsignal = process.emit.bind(process, type, type); | ||
| 30 | + wrap.onsignal = FunctionPrototypeBind(process.emit, process, type, type); | ||
| 30 | 31 | ||
| 31 | 32 | const signum = signals[type]; | |
| 32 | 33 | const err = wrap.start(signum); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments