process: deprecate process.assert()
This was never documented and the `assert` module should be used instead. PR-URL: https://github.com/nodejs/node/pull/18666 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
1bd32087ee
commit
703e37cf3f
@ -902,11 +902,21 @@ Certain versions of `node::MakeCallback` APIs available to native modules are
|
|||||||
deprecated. Please use the versions of the API that accept an `async_context`
|
deprecated. Please use the versions of the API that accept an `async_context`
|
||||||
parameter.
|
parameter.
|
||||||
|
|
||||||
|
<a id="DEP0100"></a>
|
||||||
|
### DEP0100: process.assert()
|
||||||
|
|
||||||
|
Type: Runtime
|
||||||
|
|
||||||
|
`process.assert()` is deprecated. Please use the [`assert`][] module instead.
|
||||||
|
|
||||||
|
This was never a documented feature.
|
||||||
|
|
||||||
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
|
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
|
||||||
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
|
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
|
||||||
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
|
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
|
||||||
[`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer
|
[`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer
|
||||||
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj
|
[`Buffer.isBuffer()`]: buffer.html#buffer_class_method_buffer_isbuffer_obj
|
||||||
|
[`assert`]: assert.html
|
||||||
[`clearInterval()`]: timers.html#timers_clearinterval_timeout
|
[`clearInterval()`]: timers.html#timers_clearinterval_timeout
|
||||||
[`clearTimeout()`]: timers.html#timers_cleartimeout_timeout
|
[`clearTimeout()`]: timers.html#timers_cleartimeout_timeout
|
||||||
[`EventEmitter.listenerCount(emitter, eventName)`]: events.html#events_eventemitter_listenercount_emitter_eventname
|
[`EventEmitter.listenerCount(emitter, eventName)`]: events.html#events_eventemitter_listenercount_emitter_eventname
|
||||||
|
@ -3,11 +3,15 @@
|
|||||||
const errors = require('internal/errors');
|
const errors = require('internal/errors');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const constants = process.binding('constants').os.signals;
|
const constants = process.binding('constants').os.signals;
|
||||||
|
const assert = require('assert').strict;
|
||||||
|
const { deprecate } = require('internal/util');
|
||||||
|
|
||||||
const assert = process.assert = function(x, msg) {
|
process.assert = deprecate(
|
||||||
|
function(x, msg) {
|
||||||
if (!x) throw new errors.Error('ERR_ASSERTION', msg || 'assertion error');
|
if (!x) throw new errors.Error('ERR_ASSERTION', msg || 'assertion error');
|
||||||
};
|
},
|
||||||
|
'process.assert() is deprecated. Please use the `assert` module instead.',
|
||||||
|
'DEP0100');
|
||||||
|
|
||||||
function setup_performance() {
|
function setup_performance() {
|
||||||
require('perf_hooks');
|
require('perf_hooks');
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
common.expectWarning(
|
||||||
|
'DeprecationWarning',
|
||||||
|
'process.assert() is deprecated. Please use the `assert` module instead.',
|
||||||
|
'DEP0100'
|
||||||
|
);
|
||||||
|
|
||||||
assert.strictEqual(process.assert(1, 'error'), undefined);
|
assert.strictEqual(process.assert(1, 'error'), undefined);
|
||||||
common.expectsError(() => {
|
common.expectsError(() => {
|
||||||
process.assert(undefined, 'errorMessage');
|
process.assert(undefined, 'errorMessage');
|
||||||
@ -9,13 +15,11 @@ common.expectsError(() => {
|
|||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: 'errorMessage'
|
message: 'errorMessage'
|
||||||
}
|
});
|
||||||
);
|
|
||||||
common.expectsError(() => {
|
common.expectsError(() => {
|
||||||
process.assert(false);
|
process.assert(false);
|
||||||
}, {
|
}, {
|
||||||
code: 'ERR_ASSERTION',
|
code: 'ERR_ASSERTION',
|
||||||
type: Error,
|
type: Error,
|
||||||
message: 'assertion error'
|
message: 'assertion error'
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user