mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
console: make .assert standard compliant
The standard does not throw and has no stack trace. See https://console.spec.whatwg.org/#assert PR-URL: https://github.com/nodejs/node/pull/17706 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
9ca4ab1317
commit
15d880bcb6
3 changed files with 28 additions and 66 deletions
|
@ -194,7 +194,8 @@ Console.prototype.trace = function trace(...args) {
|
|||
|
||||
Console.prototype.assert = function assert(expression, ...args) {
|
||||
if (!expression) {
|
||||
require('assert').ok(false, util.format.apply(null, args));
|
||||
args[0] = `Assertion failed${args.length === 0 ? '' : `: ${args[0]}`}`;
|
||||
this.warn(util.format.apply(null, args));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue