mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
doc: improve process.emitWarning() example
PR-URL: https://github.com/nodejs/node/pull/9590 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
1 parent
3b4ec5f6c5
commit
25a6f88d98
1 file changed
+2
-3
+2
-3
@@ -821,11 +821,10 @@ so, it is recommended to place the `emitWarning()` behind a simple boolean
|
||||
flag as illustrated in the example below:
|
||||
|
||||
```js
|
||||
var warned = false;
|
||||
function emitMyWarning() {
|
||||
if (!warned) {
|
||||
if (!emitMyWarning.warned) {
|
||||
emitMyWarning.warned = true;
|
||||
process.emitWarning('Only warn once!');
|
||||
warned = true;
|
||||
}
|
||||
}
|
||||
emitMyWarning();
|
||||
|
||||
Reference in new issue
Block a user