Skip to content

Nodepp : Stable Release : V1.3.0

Latest

Choose a tag to compare

@EDBCREPO EDBCREPO released this 28 Nov 15:20
· 2 commits to main since this release
  • πŸ“Œ: Node.js-like API: Write C++ code in a syntax and structure similar to Node.js, making it easier to learn and use.
  • πŸ“Œ: Embedded-compatible: Compatible with several devices like Arduino UNO | Esp8266 | Esp32 | Stm32
  • πŸ“Œ: High-performance: Leverage the speed and efficiency of C++ for demanding applications.
  • πŸ“Œ: Scalability: Build applications that can handle large workloads and grow with your needs.
  • πŸ“Œ: Open-source: Contribute to the project's development and customize it to your specific requirements.

improvements

  • πŸ“Œ: unix char decorator have been removed from console.h and conio.h.
  • πŸ“Œ: events now are hard erased instead of soft erased to reduce memory usage.
  • πŸ“Œ: stream objects like serial_t or file_t have been refined for better control and stability.
  • πŸ“Œ: promise_t have been refined and now are supported by coroutines for better asynchronous performance.

Articles

Example

#include <nodepp/nodepp.h>
#include <nodepp/timer.h>
#include <nodepp/promise.h>

using namespace nodepp;

void onMain() { Serial.begin( 9600 );
    
    promise_t<int, except_t> delayed_promise([=](res_t<int> res, rej_t<except_t> rej) {
        console::log("Promise started, waiting for 1 second...");
        timer::timeout([=]() { res(10); }, 1000);
    }); 

    delayed_promise.emit(); // Start the asynchronous task immediately

    process::add( coroutine::add( COROUTINE(){
    coBegin
        
        console::log("Coroutine started. Pausing until promise settles...");

        coWait( delayed_promise.is_pending() );

        console::log("Promise settled! Checking result...");

        if ( delayed_promise.is_resolved() ) {
            console::done( "Resolved value:", delayed_promise.get_value().value() );
        } elif ( delayed_promise.is_rejected() ) {
            console::error("Rejected with error:", delayed_promise.get_value().error() );
        } else {
            console::error("Something Went Wrong");
        }
        
    coFinish
    }));
}