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 f8fda0d as of 2018-02-03
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
  • Loading branch information
chakrabot committed Feb 10, 2018
2 parents 2553cc9 + f8fda0d commit ff686dc
Show file tree
Hide file tree
Showing 15 changed files with 296 additions and 214 deletions.
70 changes: 47 additions & 23 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,30 +415,64 @@ parameter is an instance of an [`Error`][] then it will be thrown instead of the
`AssertionError`.

## assert.fail([message])
<!-- YAML
added: v0.1.21
-->
* `message` {any} **Default:** `'Failed'`

Throws an `AssertionError` with the provided error message or a default error
message. If the `message` parameter is an instance of an [`Error`][] then it
will be thrown instead of the `AssertionError`.

```js
const assert = require('assert').strict;

assert.fail();
// AssertionError [ERR_ASSERTION]: Failed

assert.fail('boom');
// AssertionError [ERR_ASSERTION]: boom

assert.fail(new TypeError('need array'));
// TypeError: need array
```

Using `assert.fail()` with more than two arguments is possible but deprecated.
See below for further details.

## assert.fail(actual, expected[, message[, operator[, stackStartFunction]]])
<!-- YAML
added: v0.1.21
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/REPLACEME
description: Calling `assert.fail` with more than one argument is deprecated
and emits a warning.
-->
* `actual` {any}
* `expected` {any}
* `message` {any} **Default:** `'Failed'`
* `message` {any}
* `operator` {string} **Default:** '!='
* `stackStartFunction` {Function} **Default:** `assert.fail`

Throws an `AssertionError`. If `message` is falsy, the error message is set as
the values of `actual` and `expected` separated by the provided `operator`. If
the `message` parameter is an instance of an [`Error`][] then it will be thrown
instead of the `AssertionError`. If just the two `actual` and `expected`
arguments are provided, `operator` will default to `'!='`. If `message` is
provided only it will be used as the error message, the other arguments will be
stored as properties on the thrown object. If `stackStartFunction` is provided,
all stack frames above that function will be removed from stacktrace (see
[`Error.captureStackTrace`]). If no arguments are given, the default message
`Failed` will be used.
> Stability: 0 - Deprecated: Use `assert.fail([message])` or other assert
> functions instead.
If `message` is falsy, the error message is set as the values of `actual` and
`expected` separated by the provided `operator`. If just the two `actual` and
`expected` arguments are provided, `operator` will default to `'!='`. If
`message` is provided as third argument it will be used as the error message and
the other arguments will be stored as properties on the thrown object. If
`stackStartFunction` is provided, all stack frames above that function will be
removed from stacktrace (see [`Error.captureStackTrace`]). If no arguments are
given, the default message `Failed` will be used.

```js
const assert = require('assert').strict;

assert.fail('a', 'b');
// AssertionError [ERR_ASSERTION]: 'a' != 'b'

assert.fail(1, 2, undefined, '>');
// AssertionError [ERR_ASSERTION]: 1 > 2

Expand All @@ -452,21 +486,11 @@ assert.fail(1, 2, new TypeError('need array'));
// TypeError: need array
```

*Note*: In the last two cases `actual`, `expected`, and `operator` have no
In the last three cases `actual`, `expected`, and `operator` have no
influence on the error message.

```js
assert.fail();
// AssertionError [ERR_ASSERTION]: Failed

assert.fail('boom');
// AssertionError [ERR_ASSERTION]: boom

assert.fail('a', 'b');
// AssertionError [ERR_ASSERTION]: 'a' != 'b'
```

Example use of `stackStartFunction` for truncating the exception's stacktrace:

```js
function suppressFrame() {
assert.fail('a', 'b', undefined, '!==', suppressFrame);
Expand Down
27 changes: 27 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -847,11 +847,36 @@ Type: Documentation-only
The [`crypto.fips`][] property is deprecated. Please use `crypto.setFips()`
and `crypto.getFips()` instead.
<a id="DEP0XX"></a>
### DEP0XXX: Using `assert.fail()` with more than one argument.
Type: Runtime
Using `assert.fail()` with more than one argument has no benefit over writing an
individual error message. Either use `assert.fail()` with one argument or switch
to one of the other assert methods.
<a id="DEP00XX"></a>
### DEP00XX: timers.enroll()
Type: Runtime
`timers.enroll()` is deprecated. Please use the publicly documented [`setTimeout()`][] or [`setInterval()`][] instead.
<a id="DEP00XX"></a>
### DEP00XX: timers.unenroll()
Type: Runtime
`timers.unenroll()` is deprecated. Please use the publicly documented [`clearTimeout()`][] or [`clearInterval()`][] instead.
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
[`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj
[`clearInterval()`]: timers.html#timers_clearinterval_timeout
[`clearTimeout()`]: timers.html#timers_cleartimeout_timeout
[`EventEmitter.listenerCount(emitter, eventName)`]: events.html#events_eventemitter_listenercount_emitter_eventname
[`Server.connections`]: net.html#net_server_connections
[`Server.getConnections()`]: net.html#net_server_getconnections_callback
Expand Down Expand Up @@ -881,6 +906,8 @@ and `crypto.getFips()` instead.
[`os.tmpdir()`]: os.html#os_os_tmpdir
[`punycode`]: punycode.html
[`require.extensions`]: modules.html#modules_require_extensions
[`setInterval()`]: timers.html#timers_setinterval_callback_delay_args
[`setTimeout()`]: timers.html#timers_settimeout_callback_delay_args
[`tls.CryptoStream`]: tls.html#tls_class_cryptostream
[`tls.SecureContext`]: tls.html#tls_tls_createsecurecontext_options
[`tls.SecurePair`]: tls.html#tls_class_securepair
Expand Down
2 changes: 1 addition & 1 deletion lib/_stream_transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Transform.prototype._write = function(chunk, encoding, cb) {
Transform.prototype._read = function(n) {
var ts = this._transformState;

if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
if (ts.writechunk !== null && !ts.transforming) {
ts.transforming = true;
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
} else {
Expand Down
16 changes: 14 additions & 2 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const ERR_DIFF_DEACTIVATED = 0;
const ERR_DIFF_NOT_EQUAL = 1;
const ERR_DIFF_EQUAL = 2;

let warned = false;

// The assert module provides functions that throw
// AssertionError's when particular conditions are not met. The
// assert module must conform to the following interface.
Expand Down Expand Up @@ -84,8 +86,18 @@ function fail(actual, expected, message, operator, stackStartFn) {
} else if (argsLen === 1) {
message = actual;
actual = undefined;
} else if (argsLen === 2) {
operator = '!=';
} else {
if (warned === false) {
warned = true;
process.emitWarning(
'assert.fail() with more than one argument is deprecated. ' +
'Please use assert.strictEqual() instead or only pass a message.',
'DeprecationWarning',
'DEP00XXX'
);
}
if (argsLen === 2)
operator = '!=';
}

innerFail({
Expand Down
1 change: 1 addition & 0 deletions lib/internal/v8_prof_processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const scriptFiles = [
'internal/deps/v8/tools/profile',
'internal/deps/v8/tools/profile_view',
'internal/deps/v8/tools/logreader',
'internal/deps/v8/tools/arguments',
'internal/deps/v8/tools/tickprocessor',
'internal/deps/v8/tools/SourceMap',
'internal/deps/v8/tools/tickprocessor-driver'
Expand Down
8 changes: 1 addition & 7 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,13 +785,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
// Retain chunks
if (err === 0) req._chunks = chunks;
} else {
var enc;
if (data instanceof Buffer) {
enc = 'buffer';
} else {
enc = encoding;
}
err = createWriteReq(req, this._handle, data, enc);
err = createWriteReq(req, this._handle, data, encoding);
}

if (err)
Expand Down
15 changes: 12 additions & 3 deletions lib/string_decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,11 @@ function utf8Text(buf, i) {
// character.
function utf8End(buf) {
const r = (buf && buf.length ? this.write(buf) : '');
if (this.lastNeed)
if (this.lastNeed) {
this.lastNeed = 0;
this.lastTotal = 0;
return r + '\ufffd';
}
return r;
}

Expand Down Expand Up @@ -246,6 +249,8 @@ function utf16End(buf) {
const r = (buf && buf.length ? this.write(buf) : '');
if (this.lastNeed) {
const end = this.lastTotal - this.lastNeed;
this.lastNeed = 0;
this.lastTotal = 0;
return r + this.lastChar.toString('utf16le', 0, end);
}
return r;
Expand All @@ -269,8 +274,12 @@ function base64Text(buf, i) {

function base64End(buf) {
const r = (buf && buf.length ? this.write(buf) : '');
if (this.lastNeed)
return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
if (this.lastNeed) {
const end = 3 - this.lastNeed;
this.lastNeed = 0;
this.lastTotal = 0;
return r + this.lastChar.toString('base64', 0, end);
}
return r;
}

Expand Down
18 changes: 14 additions & 4 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ function reuse(item) {


// Remove a timer. Cancels the timeout and resets the relevant timer properties.
const unenroll = exports.unenroll = function(item) {
function unenroll(item) {
// Fewer checks may be possible, but these cover everything.
if (async_hook_fields[kDestroy] > 0 &&
item &&
Expand All @@ -384,21 +384,31 @@ const unenroll = exports.unenroll = function(item) {
}
// if active is called later, then we want to make sure not to insert again
item._idleTimeout = -1;
};
}

exports.unenroll = util.deprecate(unenroll,
'timers.unenroll() is deprecated. ' +
'Please use clearTimeout instead.',
'DEP00XX');


// Make a regular object able to act as a timer by setting some properties.
// This function does not start the timer, see `active()`.
// Using existing objects as timers slightly reduces object overhead.
exports.enroll = function(item, msecs) {
function enroll(item, msecs) {
item._idleTimeout = timerInternals.validateTimerDuration(msecs);

// if this item was already in a list somewhere
// then we should unenroll it from that
if (item._idleNext) unenroll(item);

L.init(item);
};
}

exports.enroll = util.deprecate(enroll,
'timers.unenroll() is deprecated. ' +
'Please use clearTimeout instead.',
'DEP00XX');


/*
Expand Down
1 change: 1 addition & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
'deps/v8/tools/profile.js',
'deps/v8/tools/profile_view.js',
'deps/v8/tools/logreader.js',
'deps/v8/tools/arguments.js',
'deps/v8/tools/tickprocessor.js',
'deps/v8/tools/SourceMap.js',
'deps/v8/tools/tickprocessor-driver.js',
Expand Down
2 changes: 2 additions & 0 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class ModuleWrap;
V(decorated_private_symbol, "node:decorated") \
V(npn_buffer_private_symbol, "node:npnBuffer") \
V(selected_npn_buffer_private_symbol, "node:selectedNpnBuffer") \
V(napi_env, "node:napi:env") \
V(napi_wrapper, "node:napi:wrapper") \

// Strings are per-isolate primitives but Environment proxies them
// for the sake of convenience. Strings should be ASCII-only.
Expand Down
Loading

0 comments on commit ff686dc

Please sign in to comment.