1# 3.3.0 2 3 - Support EventTarget emitters in `events.once` from Node.js 12.11.0. 4 5 Now you can use the `events.once` function with objects that implement the EventTarget interface. This interface is used widely in 6 the DOM and other web APIs. 7 8 ```js 9 var events = require('events'); 10 var assert = require('assert'); 11 12 async function connect() { 13 var ws = new WebSocket('wss://example.com'); 14 await events.once(ws, 'open'); 15 assert(ws.readyState === WebSocket.OPEN); 16 } 17 18 async function onClick() { 19 await events.once(document.body, 'click'); 20 alert('you clicked the page!'); 21 } 22 ``` 23 24# 3.2.0 25 26 - Add `events.once` from Node.js 11.13.0. 27 28 To use this function, Promises must be supported in the environment. Use a polyfill like `es6-promise` if you support older browsers. 29 30# 3.1.0 (2020-01-08) 31 32`events` now matches the Node.js 11.12.0 API. 33 34 - pass through return value in wrapped `emitter.once()` listeners 35 36 Now, this works: 37 ```js 38 emitter.once('myevent', function () { return 1; }); 39 var listener = emitter.rawListeners('myevent')[0] 40 assert(listener() === 1); 41 ``` 42 Previously, `listener()` would return undefined regardless of the implementation. 43 44 Ported from https://github.com/nodejs/node/commit/acc506c2d2771dab8d7bba6d3452bc5180dff7cf 45 46 - Reduce code duplication in listener type check ([#67](https://github.com/Gozala/events/pull/67) by [@friederbluemle](https://github.com/friederbluemle)). 47 - Improve `emitter.once()` performance in some engines 48 49# 3.0.0 (2018-05-25) 50 51**This version drops support for IE8.** `events` no longer includes polyfills 52for ES5 features. If you need to support older environments, use an ES5 shim 53like [es5-shim](https://npmjs.com/package/es5-shim). Both the shim and sham 54versions of es5-shim are necessary. 55 56 - Update to events code from Node.js 10.x 57 - (semver major) Adds `off()` method 58 - Port more tests from Node.js 59 - Switch browser tests to airtap, making things more reliable 60 61# 2.1.0 (2018-05-25) 62 63 - add Emitter#rawListeners from Node.js v9.4 64 65# 2.0.0 (2018-02-02) 66 67 - Update to events code from node.js 8.x 68 - Adds `prependListener()` and `prependOnceListener()` 69 - Adds `eventNames()` method 70 - (semver major) Unwrap `once()` listeners in `listeners()` 71 - copy tests from node.js 72 73Note that this version doubles the gzipped size, jumping from 1.1KB to 2.1KB, 74due to new methods and runtime performance improvements. Be aware of that when 75upgrading. 76 77# 1.1.1 (2016-06-22) 78 79 - add more context to errors if they are not instanceof Error 80 81# 1.1.0 (2015-09-29) 82 83 - add Emitter#listerCount (to match node v4 api) 84 85# 1.0.2 (2014-08-28) 86 87 - remove un-reachable code 88 - update devDeps 89 90## 1.0.1 / 2014-05-11 91 92 - check for console.trace before using it 93 94## 1.0.0 / 2013-12-10 95 96 - Update to latest events code from node.js 0.10 97 - copy tests from node.js 98 99## 0.4.0 / 2011-07-03 ## 100 101 - Switching to graphquire@0.8.0 102 103## 0.3.0 / 2011-07-03 ## 104 105 - Switching to URL based module require. 106 107## 0.2.0 / 2011-06-10 ## 108 109 - Simplified package structure. 110 - Graphquire for dependency management. 111 112## 0.1.1 / 2011-05-16 ## 113 114 - Unhandled errors are logged via console.error 115 116## 0.1.0 / 2011-04-22 ## 117 118 - Initial release 119