My suggestion is to port or inspire by widely adopted Arduino library: http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
When I was looking into PWM implementation in nodemcu I realised PWM is too slow as it's software driven as oppose to Arduino:
https://github.com/nodemcu/nodemcu-firmware/blob/master/app/modules/pwm.c
https://github.com/nodemcu/nodemcu-firmware/blob/cdd13b1af36dfbe51f3876efab7eccf445232682/app/driver/pwm.c
So generating carrier IR frequency of 36-40kHz would be a problem
Any suggestions/ideas?