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

Commit 79b68f0

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge 98a14e0 as of 2018-03-11 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Taylor Woll <tawoll@ntdev.microsoft.com>
2 parents dfc0ee2 + 98a14e0 commit 79b68f0

Some content is hidden

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

50 files changed

+833
-299
lines changed

benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
const common = require('../common.js');
33
const { URLSearchParams } = require('url');
44
const querystring = require('querystring');
5-
const inputs = require('../fixtures/url-inputs.js').searchParams;
5+
const searchParams = require('../fixtures/url-inputs.js').searchParams;
66

77
const bench = common.createBenchmark(main, {
8-
type: Object.keys(inputs),
8+
searchParam: Object.keys(searchParams),
99
method: ['legacy', 'whatwg'],
1010
n: [1e6]
1111
});
@@ -19,27 +19,27 @@ function useLegacy(n, input) {
1919
bench.end(n);
2020
}
2121

22-
function useWHATWG(n, input) {
23-
new URLSearchParams(input);
22+
function useWHATWG(n, param) {
23+
new URLSearchParams(param);
2424
bench.start();
2525
for (var i = 0; i < n; i += 1) {
26-
new URLSearchParams(input);
26+
new URLSearchParams(param);
2727
}
2828
bench.end(n);
2929
}
3030

31-
function main({ type, n, method }) {
32-
const input = inputs[type];
33-
if (!input) {
34-
throw new Error(`Unknown input type "${type}"`);
31+
function main({ searchParam, n, method }) {
32+
const param = searchParams[searchParam];
33+
if (!param) {
34+
throw new Error(`Unknown search parameter type "${searchParam}"`);
3535
}
3636

3737
switch (method) {
3838
case 'legacy':
39-
useLegacy(n, input);
39+
useLegacy(n, param);
4040
break;
4141
case 'whatwg':
42-
useWHATWG(n, input);
42+
useWHATWG(n, param);
4343
break;
4444
default:
4545
throw new Error(`Unknown method ${method}`);

benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
const common = require('../common.js');
33
const { URLSearchParams } = require('url');
44
const querystring = require('querystring');
5-
const inputs = require('../fixtures/url-inputs.js').searchParams;
5+
const searchParams = require('../fixtures/url-inputs.js').searchParams;
66

77
const bench = common.createBenchmark(main, {
8-
type: Object.keys(inputs),
8+
searchParam: Object.keys(searchParams),
99
method: ['legacy', 'whatwg'],
1010
n: [1e6]
1111
});
@@ -20,8 +20,8 @@ function useLegacy(n, input, prop) {
2020
bench.end(n);
2121
}
2222

23-
function useWHATWG(n, input, prop) {
24-
const obj = new URLSearchParams(input);
23+
function useWHATWG(n, param, prop) {
24+
const obj = new URLSearchParams(param);
2525
obj.toString();
2626
bench.start();
2727
for (var i = 0; i < n; i += 1) {
@@ -30,18 +30,18 @@ function useWHATWG(n, input, prop) {
3030
bench.end(n);
3131
}
3232

33-
function main({ type, n, method }) {
34-
const input = inputs[type];
35-
if (!input) {
36-
throw new Error(`Unknown input type "${type}"`);
33+
function main({ searchParam, n, method }) {
34+
const param = searchParams[searchParam];
35+
if (!param) {
36+
throw new Error(`Unknown search parameter type "${searchParam}"`);
3737
}
3838

3939
switch (method) {
4040
case 'legacy':
41-
useLegacy(n, input);
41+
useLegacy(n, param);
4242
break;
4343
case 'whatwg':
44-
useWHATWG(n, input);
44+
useWHATWG(n, param);
4545
break;
4646
default:
4747
throw new Error(`Unknown method ${method}`);

benchmark/url/url-searchparams-iteration.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const assert = require('assert');
44
const { URLSearchParams } = require('url');
55

66
const bench = common.createBenchmark(main, {
7-
method: ['forEach', 'iterator'],
7+
loopMethod: ['forEach', 'iterator'],
88
n: [1e6]
99
});
1010

@@ -44,15 +44,15 @@ function iterator(n) {
4444
assert.strictEqual(noDead[1], '3rd');
4545
}
4646

47-
function main({ method, n }) {
48-
switch (method) {
47+
function main({ loopMethod, n }) {
48+
switch (loopMethod) {
4949
case 'forEach':
5050
forEach(n);
5151
break;
5252
case 'iterator':
5353
iterator(n);
5454
break;
5555
default:
56-
throw new Error(`Unknown method ${method}`);
56+
throw new Error(`Unknown method ${loopMethod}`);
5757
}
5858
}

benchmark/url/url-searchparams-read.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@ const common = require('../common.js');
33
const { URLSearchParams } = require('url');
44

55
const bench = common.createBenchmark(main, {
6-
method: ['get', 'getAll', 'has'],
6+
accessMethod: ['get', 'getAll', 'has'],
77
param: ['one', 'two', 'three', 'nonexistent'],
88
n: [2e7]
99
});
1010

1111
const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd';
1212

13-
function main({ method, param, n }) {
13+
function main({ accessMethod, param, n }) {
1414
const params = new URLSearchParams(str);
15-
const fn = params[method];
16-
if (!fn)
17-
throw new Error(`Unknown method ${method}`);
15+
if (!params[accessMethod])
16+
throw new Error(`Unknown method ${accessMethod}`);
1817

1918
bench.start();
2019
for (var i = 0; i < n; i += 1)
21-
fn(param);
20+
params[accessMethod](param);
2221
bench.end(n);
2322
}

benchmark/url/whatwg-url-idna.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const common = require('../common.js');
33
const { domainToASCII, domainToUnicode } = require('url');
44

5-
const inputs = {
5+
const domains = {
66
empty: {
77
ascii: '',
88
unicode: ''
@@ -26,13 +26,13 @@ const inputs = {
2626
};
2727

2828
const bench = common.createBenchmark(main, {
29-
input: Object.keys(inputs),
29+
domain: Object.keys(domains),
3030
to: ['ascii', 'unicode'],
3131
n: [5e6]
3232
});
3333

34-
function main({ n, to, input }) {
35-
const value = inputs[input][to];
34+
function main({ n, to, domain }) {
35+
const value = domains[domain][to];
3636
const method = to === 'ascii' ? domainToASCII : domainToUnicode;
3737

3838
bench.start();

doc/api/assert.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,43 @@ parameter is undefined, a default error message is assigned. If the `message`
312312
parameter is an instance of an [`Error`][] then it will be thrown instead of the
313313
`AssertionError`.
314314

315+
## assert.doesNotReject(block[, error][, message])
316+
<!-- YAML
317+
added: REPLACEME
318+
-->
319+
* `block` {Function}
320+
* `error` {RegExp|Function}
321+
* `message` {any}
322+
323+
Awaits for the promise returned by function `block` to complete and not be
324+
rejected. See [`assert.rejects()`][] for more details.
325+
326+
When `assert.doesNotReject()` is called, it will immediately call the `block`
327+
function, and awaits for completion.
328+
329+
Besides the async nature to await the completion behaves identically to
330+
[`assert.doesNotThrow()`][].
331+
332+
```js
333+
(async () => {
334+
await assert.doesNotReject(
335+
async () => {
336+
throw new TypeError('Wrong value');
337+
},
338+
SyntaxError
339+
);
340+
})();
341+
```
342+
343+
```js
344+
assert.doesNotReject(
345+
() => Promise.reject(new TypeError('Wrong value')),
346+
SyntaxError
347+
).then(() => {
348+
// ...
349+
});
350+
```
351+
315352
## assert.doesNotThrow(block[, error][, message])
316353
<!-- YAML
317354
added: v0.1.21
@@ -330,6 +367,11 @@ changes:
330367
Asserts that the function `block` does not throw an error. See
331368
[`assert.throws()`][] for more details.
332369

370+
Please note: Using `assert.doesNotThrow()` is actually not useful because there
371+
is no benefit by catching an error and then rethrowing it. Instead, consider
372+
adding a comment next to the specific code path that should not throw and keep
373+
error messages as expressive as possible.
374+
333375
When `assert.doesNotThrow()` is called, it will immediately call the `block`
334376
function.
335377

@@ -802,6 +844,48 @@ assert(0);
802844
// assert(0)
803845
```
804846

847+
## assert.rejects(block[, error][, message])
848+
<!-- YAML
849+
added: REPLACEME
850+
-->
851+
* `block` {Function}
852+
* `error` {RegExp|Function|Object}
853+
* `message` {any}
854+
855+
Awaits for promise returned by function `block` to be rejected.
856+
857+
When `assert.rejects()` is called, it will immediately call the `block`
858+
function, and awaits for completion.
859+
860+
Besides the async nature to await the completion behaves identically to
861+
[`assert.throws()`][].
862+
863+
If specified, `error` can be a constructor, [`RegExp`][], a validation
864+
function, or an object where each property will be tested for.
865+
866+
If specified, `message` will be the message provided by the `AssertionError` if
867+
the block fails to reject.
868+
869+
```js
870+
(async () => {
871+
await assert.rejects(
872+
async () => {
873+
throw new Error('Wrong value');
874+
},
875+
Error
876+
);
877+
})();
878+
```
879+
880+
```js
881+
assert.rejects(
882+
() => Promise.reject(new Error('Wrong value')),
883+
Error
884+
).then(() => {
885+
// ...
886+
});
887+
```
888+
805889
## assert.strictEqual(actual, expected[, message])
806890
<!-- YAML
807891
added: v0.1.21
@@ -967,9 +1051,11 @@ second argument. This might lead to difficult-to-spot errors.
9671051
[`WeakSet`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
9681052
[`assert.deepEqual()`]: #assert_assert_deepequal_actual_expected_message
9691053
[`assert.deepStrictEqual()`]: #assert_assert_deepstrictequal_actual_expected_message
1054+
[`assert.doesNotThrow()`]: #assert_assert_doesnotthrow_block_error_message
9701055
[`assert.notDeepStrictEqual()`]: #assert_assert_notdeepstrictequal_actual_expected_message
9711056
[`assert.notStrictEqual()`]: #assert_assert_notstrictequal_actual_expected_message
9721057
[`assert.ok()`]: #assert_assert_ok_value_message
1058+
[`assert.rejects()`]: #assert_assert_rejects_block_error_message
9731059
[`assert.strictEqual()`]: #assert_assert_strictequal_actual_expected_message
9741060
[`assert.throws()`]: #assert_assert_throws_block_error_message
9751061
[`strict mode`]: #assert_strict_mode

doc/api/deprecations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,16 @@ The `tls.createSecurePair()` API was deprecated in documentation in Node.js
560560
<a id="DEP0065"></a>
561561
### DEP0065: repl.REPL_MODE_MAGIC and NODE_REPL_MODE=magic
562562

563-
Type: Documentation-only
563+
Type: End-of-Life
564564

565565
The `repl` module's `REPL_MODE_MAGIC` constant, used for `replMode` option, has
566-
been deprecated. Its behavior has been functionally identical to that of
566+
been removed. Its behavior has been functionally identical to that of
567567
`REPL_MODE_SLOPPY` since Node.js v6.0.0, when V8 5.0 was imported. Please use
568568
`REPL_MODE_SLOPPY` instead.
569569

570570
The `NODE_REPL_MODE` environment variable is used to set the underlying
571-
`replMode` of an interactive `node` session. Its default value, `magic`, is
572-
similarly deprecated in favor of `sloppy`.
571+
`replMode` of an interactive `node` session. Its value, `magic`, is also
572+
removed. Please use `sloppy` instead.
573573

574574
<a id="DEP0066"></a>
575575
### DEP0066: outgoingMessage.\_headers, outgoingMessage.\_headerNames

doc/api/repl.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ Returns `true` if `keyword` is a valid keyword, otherwise `false`.
421421
<!-- YAML
422422
added: v0.1.91
423423
changes:
424+
- version: REPLACEME
425+
pr-url: https://github.com/nodejs/node/pull/REPLACEME
426+
description: The `REPL_MAGIC_MODE` replMode was removed.
424427
- version: v5.8.0
425428
pr-url: https://github.com/nodejs/node/pull/5388
426429
description: The `options` parameter is optional now.
@@ -462,9 +465,6 @@ changes:
462465
* `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode.
463466
* `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is
464467
equivalent to prefacing every repl statement with `'use strict'`.
465-
* `repl.REPL_MODE_MAGIC` - This value is **deprecated**, since enhanced
466-
spec compliance in V8 has rendered magic mode unnecessary. It is now
467-
equivalent to `repl.REPL_MODE_SLOPPY` (documented above).
468468
* `breakEvalOnSigint` - Stop evaluating the current piece of code when
469469
`SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together
470470
with a custom `eval` function. Defaults to `false`.
@@ -512,9 +512,8 @@ environment variables:
512512
REPL history. Whitespace will be trimmed from the value.
513513
- `NODE_REPL_HISTORY_SIZE` - Defaults to `1000`. Controls how many lines of
514514
history will be persisted if history is available. Must be a positive number.
515-
- `NODE_REPL_MODE` - May be any of `sloppy`, `strict`, or `magic`. Defaults
516-
to `sloppy`, which will allow non-strict mode code to be run. `magic` is
517-
**deprecated** and treated as an alias of `sloppy`.
515+
- `NODE_REPL_MODE` - May be either `sloppy` or `strict`. Defaults
516+
to `sloppy`, which will allow non-strict mode code to be run.
518517

519518
### Persistent History
520519

doc/api/stream.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ The `stream` module can be accessed using:
2121
const stream = require('stream');
2222
```
2323

24-
While it is important for all Node.js users to understand how streams work,
25-
the `stream` module itself is most useful for developers that are creating new
26-
types of stream instances. Developers who are primarily *consuming* stream
27-
objects will rarely (if ever) have need to use the `stream` module directly.
24+
While it is important to understand how streams work, the `stream` module itself
25+
is most useful for developers that are creating new types of stream instances.
26+
Developers who are primarily *consuming* stream objects will rarely need to use
27+
the `stream` module directly.
2828

2929
## Organization of this Document
3030

0 commit comments

Comments
 (0)