NodeJs porting of original Php library