capture-stdio.js
v1.0.2
Published
A utility to capture standard output and error streams in Node.js applications.
Readme
capture-stdio.js
A utility to capture standard output and error streams in Node.js applications.
It is typically used in test cases.
Installation
npm install capture-stdio.js --saveUsage
import { captureSync, captureAsync } from "capture-stdio.js";
const { stdout, stderr } = captureSync(() => {
console.log("This is a synchronous log.");
console.error("This is a synchronous error.");
});
console.log("Synchronous Output:", stdout);
console.log("Synchronous Error:", stderr);
(async () => {
const { stdout, stderr } = await captureAsync(async () => {
console.log("This is an asynchronous log.");
console.error("This is an asynchronous error.");
});
console.log("Asynchronous Output:", stdout);
console.log("Asynchronous Error:", stderr);
})();License
The Anti 996 License
