nodepp icon indicating copy to clipboard operation
nodepp copied to clipboard

read from stdin

Open bftjoe opened this issue 1 year ago • 1 comments

Can you please make an example of reading from stdin asynchronously? I see one for writing but not reading.

bftjoe avatar Jan 27 '25 01:01 bftjoe

#include <nodepp/nodepp.h>
#include <nodepp/fs.h>

using namespace nodepp;

void onMain() {

    console::log( "write something asynchronously" );

    auto output = fs::std_output(); // writable file stream
    auto input  = fs::std_input();  // readable file stream
    auto error  = fs::std_error();  // writable file stream

    input.onData([=]( string_t data ){
        output.write( "your input is: " );
        output.write( data );
        output.write( "\n" );
    });

    stream::pipe( input );

}

EDBCREPO avatar Jan 27 '25 14:01 EDBCREPO