Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 0b3e40c

Browse files
committed
Merge nodejs/master
Merge 5100cc6 as of 2017-07-04. This is an automatically created merge. For any problems please contact @kunalspathak.
2 parents 98b06ae + 5100cc6 commit 0b3e40c

File tree

406 files changed

+1327
-2049
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

406 files changed

+1327
-2049
lines changed

.eslintrc.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ rules:
7878
no-delete-var: 2
7979
no-undef: 2
8080
no-unused-vars: [2, {args: none}]
81+
no-use-before-define: [2, {classes: true,
82+
functions: false,
83+
variables: false}]
8184

8285
# Node.js and CommonJS
8386
# http://eslint.org/docs/rules/#nodejs-and-commonjs

doc/api/console.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@ console.log('count:', count);
246246
// Prints: count: 5, to stdout
247247
```
248248

249-
If formatting elements (e.g. `%d`) are not found in the first string then
250-
[`util.inspect()`][] is called on each argument and the resulting string
251-
values are concatenated. See [`util.format()`][] for more information.
249+
See [`util.format()`][] for more information.
252250

253251
### console.time(label)
254252
<!-- YAML

doc/api/crypto.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,8 +1643,8 @@ added: v1.1.0
16431643
- `key` {string} A PEM encoded private key.
16441644
- `passphrase` {string} An optional passphrase for the private key.
16451645
- `padding` {crypto.constants} An optional padding value defined in
1646-
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
1647-
`RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
1646+
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or
1647+
`RSA_PKCS1_PADDING`.
16481648
- `buffer` {Buffer | TypedArray | DataView}
16491649

16501650
Decrypts `buffer` with `publicKey`.

doc/api/util.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,17 @@ util.format('%s:%s', 'foo');
177177
// Returns: 'foo:%s'
178178
```
179179

180-
If there are more arguments passed to the `util.format()` method than the
181-
number of placeholders, the extra arguments are coerced into strings (for
182-
objects and symbols, `util.inspect()` is used) then concatenated to the
183-
returned string, each delimited by a space.
180+
If there are more arguments passed to the `util.format()` method than the number
181+
of placeholders, the extra arguments are coerced into strings then concatenated
182+
to the returned string, each delimited by a space. Excessive arguments whose
183+
`typeof` is `'object'` or `'symbol'` (except `null`) will be transformed by
184+
`util.inspect()`.
184185

185186
```js
186187
util.format('%s:%s', 'foo', 'bar', 'baz'); // 'foo:bar baz'
187188
```
188189

189-
If the first argument is not a format string then `util.format()` returns
190+
If the first argument is not a string then `util.format()` returns
190191
a string that is the concatenation of all arguments separated by spaces.
191192
Each argument is converted to a string using `util.inspect()`.
192193

lib/_http_agent.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/*legacy*/,
181181
} else if (sockLen < this.maxSockets) {
182182
debug('call onSocket', sockLen, freeLen);
183183
// If we are under maxSockets create a new one.
184-
this.createSocket(req, options, function(err, newSocket) {
185-
if (err) {
186-
nextTick(newSocket._handle.getAsyncId(), function() {
187-
req.emit('error', err);
188-
});
189-
return;
190-
}
191-
req.onSocket(newSocket);
192-
});
184+
this.createSocket(req, options, handleSocketCreation(req, true));
193185
} else {
194186
debug('wait for socket');
195187
// We are over limit so we'll add it to the queue.
@@ -222,6 +214,7 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) {
222214
const newSocket = self.createConnection(options, oncreate);
223215
if (newSocket)
224216
oncreate(null, newSocket);
217+
225218
function oncreate(err, s) {
226219
if (called)
227220
return;
@@ -294,15 +287,7 @@ Agent.prototype.removeSocket = function removeSocket(s, options) {
294287
debug('removeSocket, have a request, make a socket');
295288
var req = this.requests[name][0];
296289
// If we have pending requests and a socket gets closed make a new one
297-
this.createSocket(req, options, function(err, newSocket) {
298-
if (err) {
299-
nextTick(newSocket._handle.getAsyncId(), function() {
300-
req.emit('error', err);
301-
});
302-
return;
303-
}
304-
newSocket.emit('free');
305-
});
290+
this.createSocket(req, options, handleSocketCreation(req, false));
306291
}
307292
};
308293

@@ -332,6 +317,22 @@ Agent.prototype.destroy = function destroy() {
332317
}
333318
};
334319

320+
function handleSocketCreation(request, informRequest) {
321+
return function handleSocketCreation_Inner(err, socket) {
322+
if (err) {
323+
const asyncId = (socket && socket._handle && socket._handle.getAsyncId) ?
324+
socket._handle.getAsyncId() :
325+
null;
326+
nextTick(asyncId, () => request.emit('error', err));
327+
return;
328+
}
329+
if (informRequest)
330+
request.onSocket(socket);
331+
else
332+
socket.emit('free');
333+
};
334+
}
335+
335336
module.exports = {
336337
Agent,
337338
globalAgent: new Agent()

lib/_http_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function writeHead(statusCode, reason, obj) {
187187
statusCode |= 0;
188188
if (statusCode < 100 || statusCode > 999) {
189189
throw new errors.RangeError('ERR_HTTP_INVALID_STATUS_CODE',
190-
originalStatusCode);
190+
originalStatusCode);
191191
}
192192

193193

lib/internal/url.js

Lines changed: 106 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,112 @@ class URLContext {
9090
}
9191
}
9292

93+
class URLSearchParams {
94+
// URL Standard says the default value is '', but as undefined and '' have
95+
// the same result, undefined is used to prevent unnecessary parsing.
96+
// Default parameter is necessary to keep URLSearchParams.length === 0 in
97+
// accordance with Web IDL spec.
98+
constructor(init = undefined) {
99+
if (init === null || init === undefined) {
100+
this[searchParams] = [];
101+
} else if ((typeof init === 'object' && init !== null) ||
102+
typeof init === 'function') {
103+
const method = init[Symbol.iterator];
104+
if (method === this[Symbol.iterator]) {
105+
// While the spec does not have this branch, we can use it as a
106+
// shortcut to avoid having to go through the costly generic iterator.
107+
const childParams = init[searchParams];
108+
this[searchParams] = childParams.slice();
109+
} else if (method !== null && method !== undefined) {
110+
if (typeof method !== 'function') {
111+
throw new errors.TypeError('ERR_ARG_NOT_ITERABLE', 'Query pairs');
112+
}
113+
114+
// sequence<sequence<USVString>>
115+
// Note: per spec we have to first exhaust the lists then process them
116+
const pairs = [];
117+
for (const pair of init) {
118+
if ((typeof pair !== 'object' && typeof pair !== 'function') ||
119+
pair === null ||
120+
typeof pair[Symbol.iterator] !== 'function') {
121+
throw new errors.TypeError('ERR_INVALID_TUPLE', 'Each query pair',
122+
'[name, value]');
123+
}
124+
const convertedPair = [];
125+
for (const element of pair)
126+
convertedPair.push(toUSVString(element));
127+
pairs.push(convertedPair);
128+
}
129+
130+
this[searchParams] = [];
131+
for (const pair of pairs) {
132+
if (pair.length !== 2) {
133+
throw new errors.TypeError('ERR_INVALID_TUPLE', 'Each query pair',
134+
'[name, value]');
135+
}
136+
this[searchParams].push(pair[0], pair[1]);
137+
}
138+
} else {
139+
// record<USVString, USVString>
140+
// Need to use reflection APIs for full spec compliance.
141+
this[searchParams] = [];
142+
const keys = Reflect.ownKeys(init);
143+
for (var i = 0; i < keys.length; i++) {
144+
const key = keys[i];
145+
const desc = Reflect.getOwnPropertyDescriptor(init, key);
146+
if (desc !== undefined && desc.enumerable) {
147+
const typedKey = toUSVString(key);
148+
const typedValue = toUSVString(init[key]);
149+
this[searchParams].push(typedKey, typedValue);
150+
}
151+
}
152+
}
153+
} else {
154+
// USVString
155+
init = toUSVString(init);
156+
if (init[0] === '?') init = init.slice(1);
157+
initSearchParams(this, init);
158+
}
159+
160+
// "associated url object"
161+
this[context] = null;
162+
}
163+
164+
[util.inspect.custom](recurseTimes, ctx) {
165+
if (!this || !this[searchParams] || this[searchParams][searchParams]) {
166+
throw new errors.TypeError('ERR_INVALID_THIS', 'URLSearchParams');
167+
}
168+
169+
if (typeof recurseTimes === 'number' && recurseTimes < 0)
170+
return ctx.stylize('[Object]', 'special');
171+
172+
var separator = ', ';
173+
var innerOpts = Object.assign({}, ctx);
174+
if (recurseTimes !== null) {
175+
innerOpts.depth = recurseTimes - 1;
176+
}
177+
var innerInspect = (v) => util.inspect(v, innerOpts);
178+
179+
var list = this[searchParams];
180+
var output = [];
181+
for (var i = 0; i < list.length; i += 2)
182+
output.push(`${innerInspect(list[i])} => ${innerInspect(list[i + 1])}`);
183+
184+
var colorRe = /\u001b\[\d\d?m/g;
185+
var length = output.reduce(
186+
(prev, cur) => prev + cur.replace(colorRe, '').length + separator.length,
187+
-separator.length
188+
);
189+
if (length > ctx.breakLength) {
190+
return `${this.constructor.name} {\n ${output.join(',\n ')} }`;
191+
} else if (output.length) {
192+
return `${this.constructor.name} { ${output.join(separator)} }`;
193+
} else {
194+
return `${this.constructor.name} {}`;
195+
}
196+
}
197+
}
198+
93199
function onParseComplete(flags, protocol, username, password,
94200
host, port, path, query, fragment) {
95201
var ctx = this[context];
@@ -806,112 +912,6 @@ function defineIDLClass(proto, classStr, obj) {
806912
}
807913
}
808914

809-
class URLSearchParams {
810-
// URL Standard says the default value is '', but as undefined and '' have
811-
// the same result, undefined is used to prevent unnecessary parsing.
812-
// Default parameter is necessary to keep URLSearchParams.length === 0 in
813-
// accordance with Web IDL spec.
814-
constructor(init = undefined) {
815-
if (init === null || init === undefined) {
816-
this[searchParams] = [];
817-
} else if ((typeof init === 'object' && init !== null) ||
818-
typeof init === 'function') {
819-
const method = init[Symbol.iterator];
820-
if (method === this[Symbol.iterator]) {
821-
// While the spec does not have this branch, we can use it as a
822-
// shortcut to avoid having to go through the costly generic iterator.
823-
const childParams = init[searchParams];
824-
this[searchParams] = childParams.slice();
825-
} else if (method !== null && method !== undefined) {
826-
if (typeof method !== 'function') {
827-
throw new errors.TypeError('ERR_ARG_NOT_ITERABLE', 'Query pairs');
828-
}
829-
830-
// sequence<sequence<USVString>>
831-
// Note: per spec we have to first exhaust the lists then process them
832-
const pairs = [];
833-
for (const pair of init) {
834-
if ((typeof pair !== 'object' && typeof pair !== 'function') ||
835-
pair === null ||
836-
typeof pair[Symbol.iterator] !== 'function') {
837-
throw new errors.TypeError('ERR_INVALID_TUPLE', 'Each query pair',
838-
'[name, value]');
839-
}
840-
const convertedPair = [];
841-
for (const element of pair)
842-
convertedPair.push(toUSVString(element));
843-
pairs.push(convertedPair);
844-
}
845-
846-
this[searchParams] = [];
847-
for (const pair of pairs) {
848-
if (pair.length !== 2) {
849-
throw new errors.TypeError('ERR_INVALID_TUPLE', 'Each query pair',
850-
'[name, value]');
851-
}
852-
this[searchParams].push(pair[0], pair[1]);
853-
}
854-
} else {
855-
// record<USVString, USVString>
856-
// Need to use reflection APIs for full spec compliance.
857-
this[searchParams] = [];
858-
const keys = Reflect.ownKeys(init);
859-
for (var i = 0; i < keys.length; i++) {
860-
const key = keys[i];
861-
const desc = Reflect.getOwnPropertyDescriptor(init, key);
862-
if (desc !== undefined && desc.enumerable) {
863-
const typedKey = toUSVString(key);
864-
const typedValue = toUSVString(init[key]);
865-
this[searchParams].push(typedKey, typedValue);
866-
}
867-
}
868-
}
869-
} else {
870-
// USVString
871-
init = toUSVString(init);
872-
if (init[0] === '?') init = init.slice(1);
873-
initSearchParams(this, init);
874-
}
875-
876-
// "associated url object"
877-
this[context] = null;
878-
}
879-
880-
[util.inspect.custom](recurseTimes, ctx) {
881-
if (!this || !this[searchParams] || this[searchParams][searchParams]) {
882-
throw new errors.TypeError('ERR_INVALID_THIS', 'URLSearchParams');
883-
}
884-
885-
if (typeof recurseTimes === 'number' && recurseTimes < 0)
886-
return ctx.stylize('[Object]', 'special');
887-
888-
var separator = ', ';
889-
var innerOpts = Object.assign({}, ctx);
890-
if (recurseTimes !== null) {
891-
innerOpts.depth = recurseTimes - 1;
892-
}
893-
var innerInspect = (v) => util.inspect(v, innerOpts);
894-
895-
var list = this[searchParams];
896-
var output = [];
897-
for (var i = 0; i < list.length; i += 2)
898-
output.push(`${innerInspect(list[i])} => ${innerInspect(list[i + 1])}`);
899-
900-
var colorRe = /\u001b\[\d\d?m/g;
901-
var length = output.reduce(
902-
(prev, cur) => prev + cur.replace(colorRe, '').length + separator.length,
903-
-separator.length
904-
);
905-
if (length > ctx.breakLength) {
906-
return `${this.constructor.name} {\n ${output.join(',\n ')} }`;
907-
} else if (output.length) {
908-
return `${this.constructor.name} { ${output.join(separator)} }`;
909-
} else {
910-
return `${this.constructor.name} {}`;
911-
}
912-
}
913-
}
914-
915915
// for merge sort
916916
function merge(out, start, mid, end, lBuffer, rBuffer) {
917917
const sizeLeft = mid - start;

lib/repl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ function complete(line, callback) {
740740
var completeOn, i, group, c;
741741

742742
// REPL commands (e.g. ".break").
743+
var filter;
743744
var match = null;
744745
match = line.match(/^\s*\.(\w*)$/);
745746
if (match) {
@@ -759,7 +760,7 @@ function complete(line, callback) {
759760

760761
completeOn = match[1];
761762
var subdir = match[2] || '';
762-
var filter = match[1];
763+
filter = match[1];
763764
var dir, files, f, name, base, ext, abs, subfiles, s;
764765
group = [];
765766
var paths = module.paths.concat(require('module').globalPaths);

test/abort/test-abort-backtrace.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
'use strict';
22
const common = require('../common');
3+
if (common.isWindows)
4+
common.skip('Backtraces unimplemented on Windows.');
5+
36
const assert = require('assert');
47
const cp = require('child_process');
58

6-
if (common.isWindows) {
7-
common.skip('Backtraces unimplemented on Windows.');
8-
return;
9-
}
10-
119
if (process.argv[2] === 'child') {
1210
process.abort();
1311
} else {

0 commit comments

Comments
 (0)