Skip to content

Commit 2707beb

Browse files
juanarbolBridgeAR
authored andcommitted
doc: add code example to process.throwDeprecation property
PR-URL: #29495 Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 123437b commit 2707beb

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

doc/api/process.md

+21-4
Original file line numberDiff line numberDiff line change
@@ -2224,11 +2224,28 @@ added: v0.9.12
22242224

22252225
* {boolean}
22262226

2227-
The `process.throwDeprecation` property indicates whether the
2228-
`--throw-deprecation` flag is set on the current Node.js process. See the
2227+
The initial value of `process.throwDeprecation` indicates whether the
2228+
`--throw-deprecation` flag is set on the current Node.js process.
2229+
`process.throwDeprecation` is mutable, so whether or not deprecation
2230+
warnings result in errors may be altered at runtime. See the
22292231
documentation for the [`'warning'` event][process_warning] and the
2230-
[`emitWarning()` method][process_emit_warning] for more information about this
2231-
flag's behavior.
2232+
[`emitWarning()` method][process_emit_warning] for more information.
2233+
2234+
```console
2235+
$ node --throw-deprecation -p "process.throwDeprecation"
2236+
true
2237+
$ node -p "process.throwDeprecation"
2238+
undefined
2239+
$ node
2240+
> process.emitWarning('test', 'DeprecationWarning');
2241+
undefined
2242+
> (node:26598) DeprecationWarning: test
2243+
> process.throwDeprecation = true;
2244+
true
2245+
> process.emitWarning('test', 'DeprecationWarning');
2246+
Thrown:
2247+
{ [DeprecationWarning: test] name: 'DeprecationWarning' }
2248+
```
22322249

22332250
## process.title
22342251
<!-- YAML

0 commit comments

Comments
 (0)