doc: revise strict mode text in assert
Revise the text describing `strict` mode. PR-URL: https://github.com/nodejs/node/pull/28285 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
bfe4c9c2c0
commit
3af27f86b6
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
The `assert` module provides a set of assertion functions for verifying
|
The `assert` module provides a set of assertion functions for verifying
|
||||||
invariants. The module provides a recommended [`strict` mode][] and a more
|
invariants. The module provides a recommended [`strict` mode][] and a more
|
||||||
lenient `legacy` mode.
|
lenient legacy mode.
|
||||||
|
|
||||||
For more information about the used equality comparisons see
|
For more information about the used equality comparisons see
|
||||||
[MDN's guide on equality comparisons and sameness][mdn-equality-guide].
|
[MDN's guide on equality comparisons and sameness][mdn-equality-guide].
|
||||||
@ -80,14 +80,14 @@ changes:
|
|||||||
description: Added strict mode to the assert module.
|
description: Added strict mode to the assert module.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
When using the `strict` mode, any `assert` function will use the equality used
|
In `strict` mode, `assert` functions use the comparison in the corresponding
|
||||||
in the strict function mode. So [`assert.deepEqual()`][] will, for example,
|
strict functions. For example, [`assert.deepEqual()`][] will behave like
|
||||||
work the same as [`assert.deepStrictEqual()`][].
|
[`assert.deepStrictEqual()`][].
|
||||||
|
|
||||||
On top of that, error messages which involve objects produce an error diff
|
In `strict` mode, error messages for objects display a diff. In legacy mode,
|
||||||
instead of displaying both objects. That is not the case for the legacy mode.
|
error messages for objects display the objects, often truncated.
|
||||||
|
|
||||||
It can be accessed using:
|
To use `strict` mode:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const assert = require('assert').strict;
|
const assert = require('assert').strict;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user