Skip to content

v3.3.0

Latest
Compare
Choose a tag to compare
@goto-bus-stop goto-bus-stop released this 27 Feb 16:52
· 1 commit to main since this release
aed9f91
  • Support EventTarget emitters in events.once from Node.js 12.11.0.

    Now you can use the events.once function with objects that implement the EventTarget interface. This interface is used widely in
    the DOM and other web APIs.

    var events = require('events');
    var assert = require('assert');
    
    async function connect() {
      var ws = new WebSocket('wss://example.com');
      await events.once(ws, 'open');
      assert(ws.readyState === WebSocket.OPEN);
    }
    
    async function onClick() {
      await events.once(document.body, 'click');
      alert('you clicked the page!');
    }