node.js implementation of /v2/waitForEvent.