@@ -173,24 +173,6 @@ Indicates whether `IPv6` is supported on this platform.
173
173
174
174
Indicates if there are multiple localhosts available.
175
175
176
- ### hijackStderr(listener)
177
- * ` listener ` [ < ; Function>] : a listener with a single parameter
178
- called ` data ` .
179
-
180
- Eavesdrop to ` process.stderr.write ` calls. Once ` process.stderr.write ` is
181
- called, ` listener ` will also be called and the ` data ` of ` write ` function will
182
- be passed to ` listener ` . What's more, ` process.stderr.writeTimes ` is a count of
183
- the number of calls.
184
-
185
- ### hijackStdout(listener)
186
- * ` listener ` [ < ; Function>] : a listener with a single parameter
187
- called ` data ` .
188
-
189
- Eavesdrop to ` process.stdout.write ` calls. Once ` process.stdout.write ` is
190
- called, ` listener ` will also be called and the ` data ` of ` write ` function will
191
- be passed to ` listener ` . What's more, ` process.stdout.writeTimes ` is a count of
192
- the number of calls.
193
-
194
176
### inFreeBSDJail
195
177
* [ < ; boolean>]
196
178
@@ -355,16 +337,6 @@ A port number for tests to use if one is needed.
355
337
356
338
Logs '1..0 # Skipped: ' + ` msg `
357
339
358
- ### restoreStderr()
359
-
360
- Restore the original ` process.stderr.write ` . Used to restore ` stderr ` to its
361
- original state after calling [ ` common.hijackStdErr() ` ] [ ] .
362
-
363
- ### restoreStdout()
364
-
365
- Restore the original ` process.stdout.write ` . Used to restore ` stdout ` to its
366
- original state after calling [ ` common.hijackStdOut() ` ] [ ] .
367
-
368
340
### rootDir
369
341
* [ < ; string>]
370
342
@@ -596,6 +568,52 @@ validateSnapshotNodes('TLSWRAP', [
596
568
]);
597
569
```
598
570
571
+ ## hijackstdio Module
572
+
573
+ The ` hijackstdio ` module provides utility functions for temporarily redirecting
574
+ ` stdout ` and ` stderr ` output.
575
+
576
+ <!-- eslint-disable no-undef, node-core/required-modules -->
577
+ ``` js
578
+ const { hijackStdout , restoreStdout } = require (' ../common/hijackstdio' );
579
+
580
+ hijackStdout ((data ) => {
581
+ /* Do something with data */
582
+ restoreStdout ();
583
+ });
584
+
585
+ console .log (' this is sent to the hijacked listener' );
586
+ ```
587
+
588
+ ### hijackStderr(listener)
589
+ * ` listener ` [ < ; Function>] : a listener with a single parameter
590
+ called ` data ` .
591
+
592
+ Eavesdrop to ` process.stderr.write() ` calls. Once ` process.stderr.write() ` is
593
+ called, ` listener ` will also be called and the ` data ` of ` write ` function will
594
+ be passed to ` listener ` . What's more, ` process.stderr.writeTimes ` is a count of
595
+ the number of calls.
596
+
597
+ ### hijackStdout(listener)
598
+ * ` listener ` [ < ; Function>] : a listener with a single parameter
599
+ called ` data ` .
600
+
601
+ Eavesdrop to ` process.stdout.write() ` calls. Once ` process.stdout.write() ` is
602
+ called, ` listener ` will also be called and the ` data ` of ` write ` function will
603
+ be passed to ` listener ` . What's more, ` process.stdout.writeTimes ` is a count of
604
+ the number of calls.
605
+
606
+ ### restoreStderr()
607
+
608
+ Restore the original ` process.stderr.write() ` . Used to restore ` stderr ` to its
609
+ original state after calling [ ` hijackstdio.hijackStdErr() ` ] [ ] .
610
+
611
+ ### restoreStdout()
612
+
613
+ Restore the original ` process.stdout.write() ` . Used to restore ` stdout ` to its
614
+ original state after calling [ ` hijackstdio.hijackStdOut() ` ] [ ] .
615
+
616
+
599
617
## HTTP/2 Module
600
618
601
619
The http2.js module provides a handful of utilities for creating mock HTTP/2
@@ -773,6 +791,6 @@ implementation with tests from
773
791
[ < ; boolean>] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type
774
792
[ < ; number>] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type
775
793
[ < ; string>] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type
776
- [ `common .hijackStdErr()` ] : #hijackstderrlistener
777
- [ `common .hijackStdOut()` ] : #hijackstdoutlistener
794
+ [ `hijackstdio .hijackStdErr()` ] : #hijackstderrlistener
795
+ [ `hijackstdio .hijackStdOut()` ] : #hijackstdoutlistener
778
796
[ internationalization ] : https://github.com/nodejs/node/wiki/Intl
0 commit comments