Skip to content

Commit 6874dee

Browse files
Trottcodebytere
authored andcommitted
doc,assert: rename "mode" to "assertion mode"
Rename "strict mode" in the assert module to "strict assertion mode". This is to avoid confusion with the more typical meaning of "strict mode" in ECMAScript. This necessitates a corresponding change of "legacy mode" to "legacy assertion mode". PR-URL: #31635 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 23fefba commit 6874dee

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

doc/api/assert.md

+28-24
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
> Stability: 2 - Stable
66
77
The `assert` module provides a set of assertion functions for verifying
8-
invariants. The module provides a recommended [`strict` mode][] and a more
9-
lenient legacy mode.
8+
invariants. The module provides a recommended [strict assertion mode][]
9+
and a more lenient legacy assertion mode.
1010

1111
## Class: assert.AssertionError
1212

@@ -68,26 +68,30 @@ try {
6868
}
6969
```
7070

71-
## Strict mode
71+
## Strict assertion mode
7272
<!-- YAML
7373
added: v9.9.0
7474
changes:
75+
- version: REPLACEME
76+
description: Changed "strict mode" to "strict assertion mode" and "legacy
77+
mode" to "legacy assertion mode" to avoid confusion with the
78+
more usual meaining of "strict mode".
7579
- version: v9.9.0
7680
pr-url: https://github.com/nodejs/node/pull/17615
77-
description: Added error diffs to the strict mode
81+
description: Added error diffs to the strict assertion mode.
7882
- version: v9.9.0
7983
pr-url: https://github.com/nodejs/node/pull/17002
80-
description: Added strict mode to the assert module.
84+
description: Added strict assertion mode to the assert module.
8185
-->
8286

83-
In `strict` mode (not to be confused with `"use strict"`), `assert` functions
84-
use the comparison in the corresponding strict functions. For example,
85-
[`assert.deepEqual()`][] will behave like [`assert.deepStrictEqual()`][].
87+
In strict assertion mode, `assert` functions use the comparison in the
88+
corresponding strict functions. For example, [`assert.deepEqual()`][] will
89+
behave like [`assert.deepStrictEqual()`][].
8690

87-
In `strict` mode, error messages for objects display a diff. In legacy mode,
88-
error messages for objects display the objects, often truncated.
91+
In strict assertion mode, error messages for objects display a diff. In legacy
92+
assertion mode, error messages for objects display the objects, often truncated.
8993

90-
To use `strict` mode:
94+
To use strict assertion mode:
9195

9296
```js
9397
const assert = require('assert').strict;
@@ -121,22 +125,22 @@ This will also deactivate the colors in the REPL.
121125
For more on the color support in terminal environments, read
122126
the tty [getColorDepth()](tty.html#tty_writestream_getcolordepth_env) doc.
123127

124-
## Legacy mode
128+
## Legacy assertion mode
125129

126-
Legacy mode uses the [Abstract Equality Comparison][] in:
130+
Legacy assertion mode uses the [Abstract Equality Comparison][] in:
127131

128132
* [`assert.deepEqual()`][]
129133
* [`assert.equal()`][]
130134
* [`assert.notDeepEqual()`][]
131135
* [`assert.notEqual()`][]
132136

133-
To use legacy mode:
137+
To use legacy assertion mode:
134138

135139
```js
136140
const assert = require('assert');
137141
```
138142

139-
Whenever possible, use the [`strict` mode][] instead. Otherwise, the
143+
Whenever possible, use the [strict assertion mode][] instead. Otherwise, the
140144
[Abstract Equality Comparison][] may cause surprising results. This is
141145
especially true for [`assert.deepEqual()`][], where the comparison rules are
142146
lax:
@@ -185,11 +189,11 @@ changes:
185189
* `expected` {any}
186190
* `message` {string|Error}
187191

188-
**Strict mode**
192+
**Strict assertion mode**
189193

190194
An alias of [`assert.deepStrictEqual()`][].
191195

192-
**Legacy mode**
196+
**Legacy assertion mode**
193197

194198
> Stability: 0 - Deprecated: Use [`assert.deepStrictEqual()`][] instead.
195199
@@ -596,11 +600,11 @@ added: v0.1.21
596600
* `expected` {any}
597601
* `message` {string|Error}
598602

599-
**Strict mode**
603+
**Strict assertion mode**
600604

601605
An alias of [`assert.strictEqual()`][].
602606

603-
**Legacy mode**
607+
**Legacy assertion mode**
604608

605609
> Stability: 0 - Deprecated: Use [`assert.strictEqual()`][] instead.
606610
@@ -825,11 +829,11 @@ changes:
825829
* `expected` {any}
826830
* `message` {string|Error}
827831

828-
**Strict mode**
832+
**Strict assertion mode**
829833

830834
An alias of [`assert.notDeepStrictEqual()`][].
831835

832-
**Legacy mode**
836+
**Legacy assertion mode**
833837

834838
> Stability: 0 - Deprecated: Use [`assert.notDeepStrictEqual()`][] instead.
835839
@@ -931,11 +935,11 @@ added: v0.1.21
931935
* `expected` {any}
932936
* `message` {string|Error}
933937

934-
**Strict mode**
938+
**Strict assertion mode**
935939

936940
An alias of [`assert.notStrictEqual()`][].
937941

938-
**Legacy mode**
942+
**Legacy assertion mode**
939943

940944
> Stability: 0 - Deprecated: Use [`assert.notStrictEqual()`][] instead.
941945
@@ -1395,7 +1399,7 @@ argument.
13951399
[`assert.ok()`]: #assert_assert_ok_value_message
13961400
[`assert.strictEqual()`]: #assert_assert_strictequal_actual_expected_message
13971401
[`assert.throws()`]: #assert_assert_throws_fn_error_message
1398-
[`strict` mode]: #assert_strict_mode
1402+
[strict assertion mode]: #assert_strict_assertion_mode
13991403
[Abstract Equality Comparison]: https://tc39.github.io/ecma262/#sec-abstract-equality-comparison
14001404
[Object wrappers]: https://developer.mozilla.org/en-US/docs/Glossary/Primitive#Primitive_wrapper_objects_in_JavaScript
14011405
[Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring

0 commit comments

Comments
 (0)