Streaming when using tofu_wrapper (#75)

Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
This commit is contained in:
Diógenes Fernandes authored and GitHub committed 2025-12-17 12:29:27 -03:00
1 parent 04ba7507e2
commit e95ccdd206
4 files changed
+20 -18

No files matched your search

+5 -2
View File
@@ -9,7 +9,8 @@
*
* @example
* // Instantiate a new listener
* const listener = new OutputListener();
* // stream is used to write the data before waiting for the listener to complete
* const listener = new OutputListener(stream);
* // Register listener against STDOUT stream
* await exec.exec('ls', ['-ltr'], {
* listeners: {
@@ -20,12 +21,14 @@
* console.log(listener.contents);
*/
class OutputListener {
constructor () {
constructor (stream) {
this._buff = [];
this._stream = stream;
}
get listener () {
const listen = function listen (data) {
this._stream.write(data);
this._buff.push(data);
};
return listen.bind(this);