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

Commit

Permalink
meta: merge node/master into node-chakracore/master
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
chakrabot committed Mar 15, 2018
2 parents dfc0ee2 + 98a14e0 commit 79b68f0
Show file tree
Hide file tree
Showing 50 changed files with 833 additions and 299 deletions.
22 changes: 11 additions & 11 deletions benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
const common = require('../common.js');
const { URLSearchParams } = require('url');
const querystring = require('querystring');
const inputs = require('../fixtures/url-inputs.js').searchParams;
const searchParams = require('../fixtures/url-inputs.js').searchParams;

const bench = common.createBenchmark(main, {
type: Object.keys(inputs),
searchParam: Object.keys(searchParams),
method: ['legacy', 'whatwg'],
n: [1e6]
});
Expand All @@ -19,27 +19,27 @@ function useLegacy(n, input) {
bench.end(n);
}

function useWHATWG(n, input) {
new URLSearchParams(input);
function useWHATWG(n, param) {
new URLSearchParams(param);
bench.start();
for (var i = 0; i < n; i += 1) {
new URLSearchParams(input);
new URLSearchParams(param);
}
bench.end(n);
}

function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
throw new Error(`Unknown input type "${type}"`);
function main({ searchParam, n, method }) {
const param = searchParams[searchParam];
if (!param) {
throw new Error(`Unknown search parameter type "${searchParam}"`);
}

switch (method) {
case 'legacy':
useLegacy(n, input);
useLegacy(n, param);
break;
case 'whatwg':
useWHATWG(n, input);
useWHATWG(n, param);
break;
default:
throw new Error(`Unknown method ${method}`);
Expand Down
20 changes: 10 additions & 10 deletions benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
const common = require('../common.js');
const { URLSearchParams } = require('url');
const querystring = require('querystring');
const inputs = require('../fixtures/url-inputs.js').searchParams;
const searchParams = require('../fixtures/url-inputs.js').searchParams;

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

function useWHATWG(n, input, prop) {
const obj = new URLSearchParams(input);
function useWHATWG(n, param, prop) {
const obj = new URLSearchParams(param);
obj.toString();
bench.start();
for (var i = 0; i < n; i += 1) {
Expand All @@ -30,18 +30,18 @@ function useWHATWG(n, input, prop) {
bench.end(n);
}

function main({ type, n, method }) {
const input = inputs[type];
if (!input) {
throw new Error(`Unknown input type "${type}"`);
function main({ searchParam, n, method }) {
const param = searchParams[searchParam];
if (!param) {
throw new Error(`Unknown search parameter type "${searchParam}"`);
}

switch (method) {
case 'legacy':
useLegacy(n, input);
useLegacy(n, param);
break;
case 'whatwg':
useWHATWG(n, input);
useWHATWG(n, param);
break;
default:
throw new Error(`Unknown method ${method}`);
Expand Down
8 changes: 4 additions & 4 deletions benchmark/url/url-searchparams-iteration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const assert = require('assert');
const { URLSearchParams } = require('url');

const bench = common.createBenchmark(main, {
method: ['forEach', 'iterator'],
loopMethod: ['forEach', 'iterator'],
n: [1e6]
});

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

function main({ method, n }) {
switch (method) {
function main({ loopMethod, n }) {
switch (loopMethod) {
case 'forEach':
forEach(n);
break;
case 'iterator':
iterator(n);
break;
default:
throw new Error(`Unknown method ${method}`);
throw new Error(`Unknown method ${loopMethod}`);
}
}
11 changes: 5 additions & 6 deletions benchmark/url/url-searchparams-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ const common = require('../common.js');
const { URLSearchParams } = require('url');

const bench = common.createBenchmark(main, {
method: ['get', 'getAll', 'has'],
accessMethod: ['get', 'getAll', 'has'],
param: ['one', 'two', 'three', 'nonexistent'],
n: [2e7]
});

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

function main({ method, param, n }) {
function main({ accessMethod, param, n }) {
const params = new URLSearchParams(str);
const fn = params[method];
if (!fn)
throw new Error(`Unknown method ${method}`);
if (!params[accessMethod])
throw new Error(`Unknown method ${accessMethod}`);

bench.start();
for (var i = 0; i < n; i += 1)
fn(param);
params[accessMethod](param);
bench.end(n);
}
8 changes: 4 additions & 4 deletions benchmark/url/whatwg-url-idna.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const common = require('../common.js');
const { domainToASCII, domainToUnicode } = require('url');

const inputs = {
const domains = {
empty: {
ascii: '',
unicode: ''
Expand All @@ -26,13 +26,13 @@ const inputs = {
};

const bench = common.createBenchmark(main, {
input: Object.keys(inputs),
domain: Object.keys(domains),
to: ['ascii', 'unicode'],
n: [5e6]
});

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

bench.start();
Expand Down
86 changes: 86 additions & 0 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,43 @@ parameter is undefined, a default error message is assigned. If the `message`
parameter is an instance of an [`Error`][] then it will be thrown instead of the
`AssertionError`.

## assert.doesNotReject(block[, error][, message])
<!-- YAML
added: REPLACEME
-->
* `block` {Function}
* `error` {RegExp|Function}
* `message` {any}

Awaits for the promise returned by function `block` to complete and not be
rejected. See [`assert.rejects()`][] for more details.

When `assert.doesNotReject()` is called, it will immediately call the `block`
function, and awaits for completion.

Besides the async nature to await the completion behaves identically to
[`assert.doesNotThrow()`][].

```js
(async () => {
await assert.doesNotReject(
async () => {
throw new TypeError('Wrong value');
},
SyntaxError
);
})();
```

```js
assert.doesNotReject(
() => Promise.reject(new TypeError('Wrong value')),
SyntaxError
).then(() => {
// ...
});
```

## assert.doesNotThrow(block[, error][, message])
<!-- YAML
added: v0.1.21
Expand All @@ -330,6 +367,11 @@ changes:
Asserts that the function `block` does not throw an error. See
[`assert.throws()`][] for more details.

Please note: Using `assert.doesNotThrow()` is actually not useful because there
is no benefit by catching an error and then rethrowing it. Instead, consider
adding a comment next to the specific code path that should not throw and keep
error messages as expressive as possible.

When `assert.doesNotThrow()` is called, it will immediately call the `block`
function.

Expand Down Expand Up @@ -802,6 +844,48 @@ assert(0);
// assert(0)
```

## assert.rejects(block[, error][, message])
<!-- YAML
added: REPLACEME
-->
* `block` {Function}
* `error` {RegExp|Function|Object}
* `message` {any}

Awaits for promise returned by function `block` to be rejected.

When `assert.rejects()` is called, it will immediately call the `block`
function, and awaits for completion.

Besides the async nature to await the completion behaves identically to
[`assert.throws()`][].

If specified, `error` can be a constructor, [`RegExp`][], a validation
function, or an object where each property will be tested for.

If specified, `message` will be the message provided by the `AssertionError` if
the block fails to reject.

```js
(async () => {
await assert.rejects(
async () => {
throw new Error('Wrong value');
},
Error
);
})();
```

```js
assert.rejects(
() => Promise.reject(new Error('Wrong value')),
Error
).then(() => {
// ...
});
```

## assert.strictEqual(actual, expected[, message])
<!-- YAML
added: v0.1.21
Expand Down Expand Up @@ -967,9 +1051,11 @@ second argument. This might lead to difficult-to-spot errors.
[`WeakSet`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
[`assert.deepEqual()`]: #assert_assert_deepequal_actual_expected_message
[`assert.deepStrictEqual()`]: #assert_assert_deepstrictequal_actual_expected_message
[`assert.doesNotThrow()`]: #assert_assert_doesnotthrow_block_error_message
[`assert.notDeepStrictEqual()`]: #assert_assert_notdeepstrictequal_actual_expected_message
[`assert.notStrictEqual()`]: #assert_assert_notstrictequal_actual_expected_message
[`assert.ok()`]: #assert_assert_ok_value_message
[`assert.rejects()`]: #assert_assert_rejects_block_error_message
[`assert.strictEqual()`]: #assert_assert_strictequal_actual_expected_message
[`assert.throws()`]: #assert_assert_throws_block_error_message
[`strict mode`]: #assert_strict_mode
Expand Down
8 changes: 4 additions & 4 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,16 +560,16 @@ The `tls.createSecurePair()` API was deprecated in documentation in Node.js
<a id="DEP0065"></a>
### DEP0065: repl.REPL_MODE_MAGIC and NODE_REPL_MODE=magic

Type: Documentation-only
Type: End-of-Life

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

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

<a id="DEP0066"></a>
### DEP0066: outgoingMessage.\_headers, outgoingMessage.\_headerNames
Expand Down
11 changes: 5 additions & 6 deletions doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ Returns `true` if `keyword` is a valid keyword, otherwise `false`.
<!-- YAML
added: v0.1.91
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/REPLACEME
description: The `REPL_MAGIC_MODE` replMode was removed.
- version: v5.8.0
pr-url: https://github.com/nodejs/node/pull/5388
description: The `options` parameter is optional now.
Expand Down Expand Up @@ -462,9 +465,6 @@ changes:
* `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode.
* `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is
equivalent to prefacing every repl statement with `'use strict'`.
* `repl.REPL_MODE_MAGIC` - This value is **deprecated**, since enhanced
spec compliance in V8 has rendered magic mode unnecessary. It is now
equivalent to `repl.REPL_MODE_SLOPPY` (documented above).
* `breakEvalOnSigint` - Stop evaluating the current piece of code when
`SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together
with a custom `eval` function. Defaults to `false`.
Expand Down Expand Up @@ -512,9 +512,8 @@ environment variables:
REPL history. Whitespace will be trimmed from the value.
- `NODE_REPL_HISTORY_SIZE` - Defaults to `1000`. Controls how many lines of
history will be persisted if history is available. Must be a positive number.
- `NODE_REPL_MODE` - May be any of `sloppy`, `strict`, or `magic`. Defaults
to `sloppy`, which will allow non-strict mode code to be run. `magic` is
**deprecated** and treated as an alias of `sloppy`.
- `NODE_REPL_MODE` - May be either `sloppy` or `strict`. Defaults
to `sloppy`, which will allow non-strict mode code to be run.

### Persistent History

Expand Down
8 changes: 4 additions & 4 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ The `stream` module can be accessed using:
const stream = require('stream');
```

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

## Organization of this Document

Expand Down
Loading

0 comments on commit 79b68f0

Please sign in to comment.