ESP32 - rotary encoder

My goal is: [use standart rotary encoder]
The result I see is: [functional esp32rotaryEncoder.h and .cpp/.js]

Hello,

im starting with mongoose and i need to use rotary encoder for my project. Im using ESP32 and í have my verified librarys for arduino IDE. I wanted to use JavaScript insted of C++ cuz of more beautiful syntax.

Anyway, i have no idea how to correctly port arduino library into mongoose, can i use C++ library in JavaScript project, or should i rewrite c++ lib into JS lib? I found
Mongoose OS Documentation (mongoose-os.com)
but im not sure how to use it.

I will be really greatfull for all advice.