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

Commit ff686dc

Browse files
committedFeb 10, 2018
meta: merge node/master into node-chakracore/master
Merge f8fda0d as of 2018-02-03 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: chakrabot <[email protected]>
2 parents 2553cc9 + f8fda0d commit ff686dc

15 files changed

+296
-214
lines changed
 

‎doc/api/assert.md

+47-23
Original file line numberDiff line numberDiff line change
@@ -415,30 +415,64 @@ parameter is an instance of an [`Error`][] then it will be thrown instead of the
415415
`AssertionError`.
416416

417417
## assert.fail([message])
418+
<!-- YAML
419+
added: v0.1.21
420+
-->
421+
* `message` {any} **Default:** `'Failed'`
422+
423+
Throws an `AssertionError` with the provided error message or a default error
424+
message. If the `message` parameter is an instance of an [`Error`][] then it
425+
will be thrown instead of the `AssertionError`.
426+
427+
```js
428+
const assert = require('assert').strict;
429+
430+
assert.fail();
431+
// AssertionError [ERR_ASSERTION]: Failed
432+
433+
assert.fail('boom');
434+
// AssertionError [ERR_ASSERTION]: boom
435+
436+
assert.fail(new TypeError('need array'));
437+
// TypeError: need array
438+
```
439+
440+
Using `assert.fail()` with more than two arguments is possible but deprecated.
441+
See below for further details.
442+
418443
## assert.fail(actual, expected[, message[, operator[, stackStartFunction]]])
419444
<!-- YAML
420445
added: v0.1.21
446+
changes:
447+
- version: REPLACEME
448+
pr-url: https://github.com/nodejs/node/pull/REPLACEME
449+
description: Calling `assert.fail` with more than one argument is deprecated
450+
and emits a warning.
421451
-->
422452
* `actual` {any}
423453
* `expected` {any}
424-
* `message` {any} **Default:** `'Failed'`
454+
* `message` {any}
425455
* `operator` {string} **Default:** '!='
426456
* `stackStartFunction` {Function} **Default:** `assert.fail`
427457

428-
Throws an `AssertionError`. If `message` is falsy, the error message is set as
429-
the values of `actual` and `expected` separated by the provided `operator`. If
430-
the `message` parameter is an instance of an [`Error`][] then it will be thrown
431-
instead of the `AssertionError`. If just the two `actual` and `expected`
432-
arguments are provided, `operator` will default to `'!='`. If `message` is
433-
provided only it will be used as the error message, the other arguments will be
434-
stored as properties on the thrown object. If `stackStartFunction` is provided,
435-
all stack frames above that function will be removed from stacktrace (see
436-
[`Error.captureStackTrace`]). If no arguments are given, the default message
437-
`Failed` will be used.
458+
> Stability: 0 - Deprecated: Use `assert.fail([message])` or other assert
459+
> functions instead.
460+
461+
If `message` is falsy, the error message is set as the values of `actual` and
462+
`expected` separated by the provided `operator`. If just the two `actual` and
463+
`expected` arguments are provided, `operator` will default to `'!='`. If
464+
`message` is provided as third argument it will be used as the error message and
465+
the other arguments will be stored as properties on the thrown object. If
466+
`stackStartFunction` is provided, all stack frames above that function will be
467+
removed from stacktrace (see [`Error.captureStackTrace`]). If no arguments are
468+
given, the default message `Failed` will be used.
438469

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

473+
assert.fail('a', 'b');
474+
// AssertionError [ERR_ASSERTION]: 'a' != 'b'
475+
442476
assert.fail(1, 2, undefined, '>');
443477
// AssertionError [ERR_ASSERTION]: 1 > 2
444478

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

455-
*Note*: In the last two cases `actual`, `expected`, and `operator` have no
489+
In the last three cases `actual`, `expected`, and `operator` have no
456490
influence on the error message.
457491

458-
```js
459-
assert.fail();
460-
// AssertionError [ERR_ASSERTION]: Failed
461-
462-
assert.fail('boom');
463-
// AssertionError [ERR_ASSERTION]: boom
464-
465-
assert.fail('a', 'b');
466-
// AssertionError [ERR_ASSERTION]: 'a' != 'b'
467-
```
468-
469492
Example use of `stackStartFunction` for truncating the exception's stacktrace:
493+
470494
```js
471495
function suppressFrame() {
472496
assert.fail('a', 'b', undefined, '!==', suppressFrame);

‎doc/api/deprecations.md

+27
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,36 @@ Type: Documentation-only
847847
The [`crypto.fips`][] property is deprecated. Please use `crypto.setFips()`
848848
and `crypto.getFips()` instead.
849849
850+
<a id="DEP0XX"></a>
851+
### DEP0XXX: Using `assert.fail()` with more than one argument.
852+
853+
Type: Runtime
854+
855+
Using `assert.fail()` with more than one argument has no benefit over writing an
856+
individual error message. Either use `assert.fail()` with one argument or switch
857+
to one of the other assert methods.
858+
859+
<a id="DEP00XX"></a>
860+
### DEP00XX: timers.enroll()
861+
862+
Type: Runtime
863+
864+
`timers.enroll()` is deprecated. Please use the publicly documented [`setTimeout()`][] or [`setInterval()`][] instead.
865+
866+
<a id="DEP00XX"></a>
867+
### DEP00XX: timers.unenroll()
868+
869+
Type: Runtime
870+
871+
`timers.unenroll()` is deprecated. Please use the publicly documented [`clearTimeout()`][] or [`clearInterval()`][] instead.
872+
850873
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
851874
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
852875
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
853876
[`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer
854877
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj
878+
[`clearInterval()`]: timers.html#timers_clearinterval_timeout
879+
[`clearTimeout()`]: timers.html#timers_cleartimeout_timeout
855880
[`EventEmitter.listenerCount(emitter, eventName)`]: events.html#events_eventemitter_listenercount_emitter_eventname
856881
[`Server.connections`]: net.html#net_server_connections
857882
[`Server.getConnections()`]: net.html#net_server_getconnections_callback
@@ -881,6 +906,8 @@ and `crypto.getFips()` instead.
881906
[`os.tmpdir()`]: os.html#os_os_tmpdir
882907
[`punycode`]: punycode.html
883908
[`require.extensions`]: modules.html#modules_require_extensions
909+
[`setInterval()`]: timers.html#timers_setinterval_callback_delay_args
910+
[`setTimeout()`]: timers.html#timers_settimeout_callback_delay_args
884911
[`tls.CryptoStream`]: tls.html#tls_class_cryptostream
885912
[`tls.SecureContext`]: tls.html#tls_tls_createsecurecontext_options
886913
[`tls.SecurePair`]: tls.html#tls_class_securepair

‎lib/_stream_transform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Transform.prototype._write = function(chunk, encoding, cb) {
180180
Transform.prototype._read = function(n) {
181181
var ts = this._transformState;
182182

183-
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
183+
if (ts.writechunk !== null && !ts.transforming) {
184184
ts.transforming = true;
185185
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
186186
} else {

‎lib/assert.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const ERR_DIFF_DEACTIVATED = 0;
5454
const ERR_DIFF_NOT_EQUAL = 1;
5555
const ERR_DIFF_EQUAL = 2;
5656

57+
let warned = false;
58+
5759
// The assert module provides functions that throw
5860
// AssertionError's when particular conditions are not met. The
5961
// assert module must conform to the following interface.
@@ -84,8 +86,18 @@ function fail(actual, expected, message, operator, stackStartFn) {
8486
} else if (argsLen === 1) {
8587
message = actual;
8688
actual = undefined;
87-
} else if (argsLen === 2) {
88-
operator = '!=';
89+
} else {
90+
if (warned === false) {
91+
warned = true;
92+
process.emitWarning(
93+
'assert.fail() with more than one argument is deprecated. ' +
94+
'Please use assert.strictEqual() instead or only pass a message.',
95+
'DeprecationWarning',
96+
'DEP00XXX'
97+
);
98+
}
99+
if (argsLen === 2)
100+
operator = '!=';
89101
}
90102

91103
innerFail({

‎lib/internal/v8_prof_processor.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const scriptFiles = [
88
'internal/deps/v8/tools/profile',
99
'internal/deps/v8/tools/profile_view',
1010
'internal/deps/v8/tools/logreader',
11+
'internal/deps/v8/tools/arguments',
1112
'internal/deps/v8/tools/tickprocessor',
1213
'internal/deps/v8/tools/SourceMap',
1314
'internal/deps/v8/tools/tickprocessor-driver'

‎lib/net.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -785,13 +785,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
785785
// Retain chunks
786786
if (err === 0) req._chunks = chunks;
787787
} else {
788-
var enc;
789-
if (data instanceof Buffer) {
790-
enc = 'buffer';
791-
} else {
792-
enc = encoding;
793-
}
794-
err = createWriteReq(req, this._handle, data, enc);
788+
err = createWriteReq(req, this._handle, data, encoding);
795789
}
796790

797791
if (err)

‎lib/string_decoder.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,11 @@ function utf8Text(buf, i) {
210210
// character.
211211
function utf8End(buf) {
212212
const r = (buf && buf.length ? this.write(buf) : '');
213-
if (this.lastNeed)
213+
if (this.lastNeed) {
214+
this.lastNeed = 0;
215+
this.lastTotal = 0;
214216
return r + '\ufffd';
217+
}
215218
return r;
216219
}
217220

@@ -246,6 +249,8 @@ function utf16End(buf) {
246249
const r = (buf && buf.length ? this.write(buf) : '');
247250
if (this.lastNeed) {
248251
const end = this.lastTotal - this.lastNeed;
252+
this.lastNeed = 0;
253+
this.lastTotal = 0;
249254
return r + this.lastChar.toString('utf16le', 0, end);
250255
}
251256
return r;
@@ -269,8 +274,12 @@ function base64Text(buf, i) {
269274

270275
function base64End(buf) {
271276
const r = (buf && buf.length ? this.write(buf) : '');
272-
if (this.lastNeed)
273-
return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
277+
if (this.lastNeed) {
278+
const end = 3 - this.lastNeed;
279+
this.lastNeed = 0;
280+
this.lastTotal = 0;
281+
return r + this.lastChar.toString('base64', 0, end);
282+
}
274283
return r;
275284
}
276285

‎lib/timers.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ function reuse(item) {
367367

368368

369369
// Remove a timer. Cancels the timeout and resets the relevant timer properties.
370-
const unenroll = exports.unenroll = function(item) {
370+
function unenroll(item) {
371371
// Fewer checks may be possible, but these cover everything.
372372
if (async_hook_fields[kDestroy] > 0 &&
373373
item &&
@@ -384,21 +384,31 @@ const unenroll = exports.unenroll = function(item) {
384384
}
385385
// if active is called later, then we want to make sure not to insert again
386386
item._idleTimeout = -1;
387-
};
387+
}
388+
389+
exports.unenroll = util.deprecate(unenroll,
390+
'timers.unenroll() is deprecated. ' +
391+
'Please use clearTimeout instead.',
392+
'DEP00XX');
388393

389394

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

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

400405
L.init(item);
401-
};
406+
}
407+
408+
exports.enroll = util.deprecate(enroll,
409+
'timers.unenroll() is deprecated. ' +
410+
'Please use clearTimeout instead.',
411+
'DEP00XX');
402412

403413

404414
/*

‎node.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
'deps/v8/tools/profile.js',
158158
'deps/v8/tools/profile_view.js',
159159
'deps/v8/tools/logreader.js',
160+
'deps/v8/tools/arguments.js',
160161
'deps/v8/tools/tickprocessor.js',
161162
'deps/v8/tools/SourceMap.js',
162163
'deps/v8/tools/tickprocessor-driver.js',

‎src/env.h

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class ModuleWrap;
9191
V(decorated_private_symbol, "node:decorated") \
9292
V(npn_buffer_private_symbol, "node:npnBuffer") \
9393
V(selected_npn_buffer_private_symbol, "node:selectedNpnBuffer") \
94+
V(napi_env, "node:napi:env") \
95+
V(napi_wrapper, "node:napi:wrapper") \
9496

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

0 commit comments

Comments
 (0)
This repository has been archived.