| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 901d3d0 commit 3350230
17 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,7 +48,7 @@ function Agent(options) { | |||
| 48 | 48 | this.defaultPort = 80; | |
| 49 | 49 | this.protocol = 'http:'; | |
| 50 | 50 | ||
| 51 | - this.options = util._extend({}, options); | ||
| 51 | + this.options = { ...options }; | ||
| 52 | 52 | ||
| 53 | 53 | // Don't confuse net and make it think that we're connecting to a pipe | |
| 54 | 54 | this.options.path = null; | |
@@ -146,8 +146,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */, | |||
| 146 | 146 | }; | |
| 147 | 147 | } | |
| 148 | 148 | ||
| 149 | - options = util._extend({}, options); | ||
| 150 | - util._extend(options, this.options); | ||
| 149 | + options = { ...options, ...this.options }; | ||
| 151 | 150 | if (options.socketPath) | |
| 152 | 151 | options.path = options.socketPath; | |
| 153 | 152 | ||
@@ -194,8 +193,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */, | |||
| 194 | 193 | }; | |
| 195 | 194 | ||
| 196 | 195 | Agent.prototype.createSocket = function createSocket(req, options, cb) { | |
| 197 | - options = util._extend({}, options); | ||
| 198 | - util._extend(options, this.options); | ||
| 196 | + options = { ...options, ...this.options }; | ||
| 199 | 197 | if (options.socketPath) | |
| 200 | 198 | options.path = options.socketPath; | |
| 201 | 199 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,11 +93,11 @@ function ClientRequest(input, options, cb) { | |||
| 93 | 93 | ||
| 94 | 94 | if (typeof options === 'function') { | |
| 95 | 95 | cb = options; | |
| 96 | - options = null; | ||
| 96 | + options = input || {}; | ||
| 97 | + } else { | ||
| 98 | + options = Object.assign(input || {}, options); | ||
| 97 | 99 | } | |
| 98 | 100 | ||
| 99 | - options = util._extend(input || {}, options || {}); | ||
| 100 | - | ||
| 101 | 101 | var agent = options.agent; | |
| 102 | 102 | var defaultAgent = options._defaultAgent || Agent.globalAgent; | |
| 103 | 103 | if (agent === false) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -280,7 +280,7 @@ function Server(options, requestListener) { | |||
| 280 | 280 | requestListener = options; | |
| 281 | 281 | options = {}; | |
| 282 | 282 | } else if (options == null || typeof options === 'object') { | |
| 283 | - options = util._extend({}, options); | ||
| 283 | + options = { ...options }; | ||
| 284 | 284 | } | |
| 285 | 285 | ||
| 286 | 286 | this[kIncomingMessage] = options.IncomingMessage || IncomingMessage; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1108,22 +1108,22 @@ function SNICallback(servername, callback) { | |||
| 1108 | 1108 | // | |
| 1109 | 1109 | // | |
| 1110 | 1110 | function normalizeConnectArgs(listArgs) { | |
| 1111 | - var args = net._normalizeArgs(listArgs); | ||
| 1112 | - var options = args[0]; | ||
| 1113 | - var cb = args[1]; | ||
| 1111 | + const args = net._normalizeArgs(listArgs); | ||
| 1112 | + const options = args[0]; | ||
| 1113 | + const cb = args[1]; | ||
| 1114 | 1114 | ||
| 1115 | 1115 | // If args[0] was options, then normalize dealt with it. | |
| 1116 | 1116 | // If args[0] is port, or args[0], args[1] is host, port, we need to | |
| 1117 | 1117 | // find the options and merge them in, normalize's options has only | |
| 1118 | 1118 | // the host/port/path args that it knows about, not the tls options. | |
| 1119 | 1119 | // This means that options.host overrides a host arg. | |
| 1120 | 1120 | if (listArgs[1] !== null && typeof listArgs[1] === 'object') { | |
| 1121 | - util._extend(options, listArgs[1]); | ||
| 1121 | + Object.assign(options, listArgs[1]); | ||
| 1122 | 1122 | } else if (listArgs[2] !== null && typeof listArgs[2] === 'object') { | |
| 1123 | - util._extend(options, listArgs[2]); | ||
| 1123 | + Object.assign(options, listArgs[2]); | ||
| 1124 | 1124 | } | |
| 1125 | 1125 | ||
| 1126 | - return (cb) ? [options, cb] : [options]; | ||
| 1126 | + return cb ? [options, cb] : [options]; | ||
| 1127 | 1127 | } | |
| 1128 | 1128 | ||
| 1129 | 1129 | function onConnectSecure() { | |
@@ -1204,14 +1204,14 @@ exports.connect = function connect(...args) { | |||
| 1204 | 1204 | 'certificate verification.'); | |
| 1205 | 1205 | } | |
| 1206 | 1206 | ||
| 1207 | - var defaults = { | ||
| 1207 | + options = { | ||
| 1208 | 1208 | rejectUnauthorized: !allowUnauthorized, | |
| 1209 | 1209 | ciphers: tls.DEFAULT_CIPHERS, | |
| 1210 | 1210 | checkServerIdentity: tls.checkServerIdentity, | |
| 1211 | - minDHSize: 1024 | ||
| 1211 | + minDHSize: 1024, | ||
| 1212 | + ...options | ||
| 1212 | 1213 | }; | |
| 1213 | 1214 | ||
| 1214 | - options = util._extend(defaults, options || {}); | ||
| 1215 | 1215 | if (!options.keepAlive) | |
| 1216 | 1216 | options.singleUse = true; | |
| 1217 | 1217 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,7 +79,7 @@ exports.fork = function fork(modulePath /* , args, options */) { | |||
| 79 | 79 | throw new ERR_INVALID_ARG_VALUE(`arguments[${pos}]`, arguments[pos]); | |
| 80 | 80 | } | |
| 81 | 81 | ||
| 82 | - options = util._extend({}, arguments[pos++]); | ||
| 82 | + options = { ...arguments[pos++] }; | ||
| 83 | 83 | } | |
| 84 | 84 | ||
| 85 | 85 | // Prepare arguments for fork: | |
@@ -176,28 +176,20 @@ Object.defineProperty(exports.exec, util.promisify.custom, { | |||
| 176 | 176 | }); | |
| 177 | 177 | ||
| 178 | 178 | exports.execFile = function execFile(file /* , args, options, callback */) { | |
| 179 | - var args = []; | ||
| 180 | - var callback; | ||
| 181 | - var options = { | ||
| 182 | - encoding: 'utf8', | ||
| 183 | - timeout: 0, | ||
| 184 | - maxBuffer: 200 * 1024, | ||
| 185 | - killSignal: 'SIGTERM', | ||
| 186 | - cwd: null, | ||
| 187 | - env: null, | ||
| 188 | - shell: false | ||
| 189 | - }; | ||
| 179 | + let args = []; | ||
| 180 | + let callback; | ||
| 181 | + let options; | ||
| 190 | 182 | ||
| 191 | 183 | // Parse the optional positional parameters. | |
| 192 | - var pos = 1; | ||
| 184 | + let pos = 1; | ||
| 193 | 185 | if (pos < arguments.length && Array.isArray(arguments[pos])) { | |
| 194 | 186 | args = arguments[pos++]; | |
| 195 | 187 | } else if (pos < arguments.length && arguments[pos] == null) { | |
| 196 | 188 | pos++; | |
| 197 | 189 | } | |
| 198 | 190 | ||
| 199 | 191 | if (pos < arguments.length && typeof arguments[pos] === 'object') { | |
| 200 | - util._extend(options, arguments[pos++]); | ||
| 192 | + options = arguments[pos++]; | ||
| 201 | 193 | } else if (pos < arguments.length && arguments[pos] == null) { | |
| 202 | 194 | pos++; | |
| 203 | 195 | } | |
@@ -210,6 +202,17 @@ exports.execFile = function execFile(file /* , args, options, callback */) { | |||
| 210 | 202 | throw new ERR_INVALID_ARG_VALUE('args', arguments[pos]); | |
| 211 | 203 | } | |
| 212 | 204 | ||
| 205 | + options = { | ||
| 206 | + encoding: 'utf8', | ||
| 207 | + timeout: 0, | ||
| 208 | + maxBuffer: 200 * 1024, | ||
| 209 | + killSignal: 'SIGTERM', | ||
| 210 | + cwd: null, | ||
| 211 | + env: null, | ||
| 212 | + shell: false, | ||
| 213 | + ...options | ||
| 214 | + }; | ||
| 215 | + | ||
| 213 | 216 | // Validate the timeout, if present. | |
| 214 | 217 | validateTimeout(options.timeout); | |
| 215 | 218 | ||
@@ -580,15 +583,15 @@ function spawnSync(file, args, options) { | |||
| 580 | 583 | options.stdio = _validateStdio(options.stdio || 'pipe', true).stdio; | |
| 581 | 584 | ||
| 582 | 585 | if (options.input) { | |
| 583 | - var stdin = options.stdio[0] = util._extend({}, options.stdio[0]); | ||
| 586 | + var stdin = options.stdio[0] = { ...options.stdio[0] }; | ||
| 584 | 587 | stdin.input = options.input; | |
| 585 | 588 | } | |
| 586 | 589 | ||
| 587 | 590 | // We may want to pass data in on any given fd, ensure it is a valid buffer | |
| 588 | 591 | for (var i = 0; i < options.stdio.length; i++) { | |
| 589 | 592 | var input = options.stdio[i] && options.stdio[i].input; | |
| 590 | 593 | if (input != null) { | |
| 591 | - var pipe = options.stdio[i] = util._extend({}, options.stdio[i]); | ||
| 594 | + var pipe = options.stdio[i] = { ...options.stdio[i] }; | ||
| 592 | 595 | if (isArrayBufferView(input)) { | |
| 593 | 596 | pipe.input = input; | |
| 594 | 597 | } else if (typeof input === 'string') { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -350,11 +350,9 @@ Domain.prototype.run = function(fn) { | |||
| 350 | 350 | function intercepted(_this, self, cb, fnargs) { | |
| 351 | 351 | if (fnargs[0] && fnargs[0] instanceof Error) { | |
| 352 | 352 | var er = fnargs[0]; | |
| 353 | - util._extend(er, { | ||
| 354 | - domainBound: cb, | ||
| 355 | - domainThrown: false, | ||
| 356 | - domain: self | ||
| 357 | - }); | ||
| 353 | + er.domainBound = cb; | ||
| 354 | + er.domainThrown = false; | ||
| 355 | + er.domain = self; | ||
| 358 | 356 | self.emit('error', er); | |
| 359 | 357 | return; | |
| 360 | 358 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,6 @@ const { | |||
| 39 | 39 | O_SYMLINK | |
| 40 | 40 | } = constants; | |
| 41 | 41 | ||
| 42 | - const { _extend } = require('util'); | ||
| 43 | 42 | const pathModule = require('path'); | |
| 44 | 43 | const { isArrayBufferView } = require('internal/util/types'); | |
| 45 | 44 | const binding = process.binding('fs'); | |
@@ -1294,21 +1293,20 @@ function watchFile(filename, options, listener) { | |||
| 1294 | 1293 | filename = pathModule.resolve(filename); | |
| 1295 | 1294 | let stat; | |
| 1296 | 1295 | ||
| 1297 | - const defaults = { | ||
| 1296 | + if (options === null || typeof options !== 'object') { | ||
| 1297 | + listener = options; | ||
| 1298 | + options = null; | ||
| 1299 | + } | ||
| 1300 | + | ||
| 1301 | + options = { | ||
| 1298 | 1302 | // Poll interval in milliseconds. 5007 is what libev used to use. It's | |
| 1299 | 1303 | // a little on the slow side but let's stick with it for now to keep | |
| 1300 | 1304 | // behavioral changes to a minimum. | |
| 1301 | 1305 | interval: 5007, | |
| 1302 | - persistent: true | ||
| 1306 | + persistent: true, | ||
| 1307 | + ...options | ||
| 1303 | 1308 | }; | |
| 1304 | 1309 | ||
| 1305 | - if (options !== null && typeof options === 'object') { | ||
| 1306 | - options = _extend(defaults, options); | ||
| 1307 | - } else { | ||
| 1308 | - listener = options; | ||
| 1309 | - options = defaults; | ||
| 1310 | - } | ||
| 1311 | - | ||
| 1312 | 1310 | if (typeof listener !== 'function') { | |
| 1313 | 1311 | throw new ERR_INVALID_ARG_TYPE('listener', 'Function', listener); | |
| 1314 | 1312 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,7 +46,7 @@ function Server(opts, requestListener) { | |||
| 46 | 46 | requestListener = opts; | |
| 47 | 47 | opts = undefined; | |
| 48 | 48 | } | |
| 49 | - opts = util._extend({}, opts); | ||
| 49 | + opts = { ...opts }; | ||
| 50 | 50 | ||
| 51 | 51 | if (!opts.ALPNProtocols) { | |
| 52 | 52 | // http/1.0 is not defined as Protocol IDs in IANA | |
@@ -110,9 +110,10 @@ function createConnection(port, host, options) { | |||
| 110 | 110 | const session = this._getSession(options._agentKey); | |
| 111 | 111 | if (session) { | |
| 112 | 112 | debug('reuse session for %j', options._agentKey); | |
| 113 | - options = util._extend({ | ||
| 114 | - session: session | ||
| 115 | - }, options); | ||
| 113 | + options = { | ||
| 114 | + session, | ||
| 115 | + ...options | ||
| 116 | + }; | ||
| 116 | 117 | } | |
| 117 | 118 | } | |
| 118 | 119 | ||
@@ -291,7 +292,7 @@ function request(...args) { | |||
| 291 | 292 | } | |
| 292 | 293 | ||
| 293 | 294 | if (args[0] && typeof args[0] !== 'function') { | |
| 294 | - options = util._extend(options, args.shift()); | ||
| 295 | + Object.assign(options, args.shift()); | ||
| 295 | 296 | } | |
| 296 | 297 | ||
| 297 | 298 | options._defaultAgent = module.exports.globalAgent; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const assert = require('assert'); | |
| 3 | - const util = require('util'); | ||
| 4 | 3 | const path = require('path'); | |
| 5 | 4 | const EventEmitter = require('events'); | |
| 6 | 5 | const { owner_symbol } = require('internal/async_hooks').symbols; | |
@@ -71,11 +70,12 @@ cluster._getServer = function(obj, options, cb) { | |||
| 71 | 70 | ||
| 72 | 71 | indexes.set(indexesKey, index); | |
| 73 | 72 | ||
| 74 | - const message = util._extend({ | ||
| 73 | + const message = { | ||
| 75 | 74 | act: 'queryServer', | |
| 76 | 75 | index, | |
| 77 | - data: null | ||
| 78 | - }, options); | ||
| 76 | + data: null, | ||
| 77 | + ...options | ||
| 78 | + }; | ||
| 79 | 79 | ||
| 80 | 80 | message.address = address; | |
| 81 | 81 | ||
@@ -151,7 +151,7 @@ function rr(message, indexesKey, cb) { | |||
| 151 | 151 | ||
| 152 | 152 | function getsockname(out) { | |
| 153 | 153 | if (key) | |
| 154 | - util._extend(out, message.sockname); | ||
| 154 | + Object.assign(out, message.sockname); | ||
| 155 | 155 | ||
| 156 | 156 | return 0; | |
| 157 | 157 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,6 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const assert = require('assert'); | |
| 3 | 3 | const { fork } = require('child_process'); | |
| 4 | - const util = require('util'); | ||
| 5 | 4 | const path = require('path'); | |
| 6 | 5 | const EventEmitter = require('events'); | |
| 7 | 6 | const RoundRobinHandle = require('internal/cluster/round_robin_handle'); | |
@@ -47,14 +46,14 @@ if (schedulingPolicy === undefined) { | |||
| 47 | 46 | cluster.schedulingPolicy = schedulingPolicy; | |
| 48 | 47 | ||
| 49 | 48 | cluster.setupMaster = function(options) { | |
| 50 | - var settings = { | ||
| 49 | + const settings = { | ||
| 51 | 50 | args: process.argv.slice(2), | |
| 52 | 51 | exec: process.argv[1], | |
| 53 | 52 | execArgv: process.execArgv, | |
| 54 | - silent: false | ||
| 53 | + silent: false, | ||
| 54 | + ...cluster.settings, | ||
| 55 | + ...options | ||
| 55 | 56 | }; | |
| 56 | - util._extend(settings, cluster.settings); | ||
| 57 | - util._extend(settings, options || {}); | ||
| 58 | 57 | ||
| 59 | 58 | // Tell V8 to write profile data for each process to a separate file. | |
| 60 | 59 | // Without --logfile=v8-%p.log, everything ends up in a single, unusable | |
@@ -101,15 +100,12 @@ function setupSettingsNT(settings) { | |||
| 101 | 100 | } | |
| 102 | 101 | ||
| 103 | 102 | function createWorkerProcess(id, env) { | |
| 104 | - const workerEnv = util._extend({}, process.env); | ||
| 103 | + const workerEnv = { ...process.env, ...env, NODE_UNIQUE_ID: `${id}` }; | ||
| 105 | 104 | const execArgv = cluster.settings.execArgv.slice(); | |
| 106 | 105 | const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/; | |
| 107 | 106 | const nodeOptions = process.env.NODE_OPTIONS ? | |
| 108 | 107 | process.env.NODE_OPTIONS : ''; | |
| 109 | 108 | ||
| 110 | - util._extend(workerEnv, env); | ||
| 111 | - workerEnv.NODE_UNIQUE_ID = '' + id; | ||
| 112 | - | ||
| 113 | 109 | if (execArgv.some((arg) => arg.match(debugArgRegex)) || | |
| 114 | 110 | nodeOptions.match(debugArgRegex)) { | |
| 115 | 111 | let inspectPort; | |
@@ -315,17 +311,18 @@ function queryServer(worker, message) { | |||
| 315 | 311 | ||
| 316 | 312 | // Set custom server data | |
| 317 | 313 | handle.add(worker, (errno, reply, handle) => { | |
| 318 | - reply = util._extend({ | ||
| 319 | - errno: errno, | ||
| 320 | - key: key, | ||
| 321 | - ack: message.seq, | ||
| 322 | - data: handles.get(key).data | ||
| 323 | - }, reply); | ||
| 314 | + const { data } = handles.get(key); | ||
| 324 | 315 | ||
| 325 | 316 | if (errno) | |
| 326 | 317 | handles.delete(key); // Gives other workers a chance to retry. | |
| 327 | 318 | ||
| 328 | - send(worker, reply, handle); | ||
| 319 | + send(worker, { | ||
| 320 | + errno, | ||
| 321 | + key, | ||
| 322 | + ack: message.seq, | ||
| 323 | + data, | ||
| 324 | + ...reply | ||
| 325 | + }, handle); | ||
| 329 | 326 | }); | |
| 330 | 327 | } | |
| 331 | 328 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments