Ported v7.3 php code to nodejs.