Working port of PAPhotonNode.js