events-runtime 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.airtap.yml +15 -0
- package/.github/FUNDING.yml +12 -0
- package/.travis.yml +18 -0
- package/History.md +118 -0
- package/LICENSE +22 -0
- package/Readme.md +50 -0
- package/events.js +497 -0
- package/package.json +47 -0
- package/security.md +10 -0
- package/tests/add-listeners.js +111 -0
- package/tests/check-listener-leaks.js +101 -0
- package/tests/common.js +104 -0
- package/tests/errors.js +13 -0
- package/tests/events-list.js +28 -0
- package/tests/events-once.js +234 -0
- package/tests/index.js +64 -0
- package/tests/legacy-compat.js +16 -0
- package/tests/listener-count.js +37 -0
- package/tests/listeners-side-effects.js +56 -0
- package/tests/listeners.js +168 -0
- package/tests/max-listeners.js +47 -0
- package/tests/method-names.js +35 -0
- package/tests/modify-in-emit.js +90 -0
- package/tests/num-args.js +60 -0
- package/tests/once.js +83 -0
- package/tests/prepend.js +31 -0
- package/tests/remove-all-listeners.js +133 -0
- package/tests/remove-listeners.js +212 -0
- package/tests/set-max-listeners-side-effects.js +31 -0
- package/tests/special-event-names.js +45 -0
- package/tests/subclass.js +66 -0
- package/tests/symbols.js +25 -0
package/.airtap.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
sauce_connect: true
|
|
2
|
+
loopback: airtap.local
|
|
3
|
+
browsers:
|
|
4
|
+
- name: chrome
|
|
5
|
+
version: latest
|
|
6
|
+
- name: firefox
|
|
7
|
+
version: latest
|
|
8
|
+
- name: safari
|
|
9
|
+
version: 9..latest
|
|
10
|
+
- name: iphone
|
|
11
|
+
version: latest
|
|
12
|
+
- name: ie
|
|
13
|
+
version: 9..latest
|
|
14
|
+
- name: microsoftedge
|
|
15
|
+
version: 13..latest
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
|
4
|
+
patreon: # Replace with a single Patreon username
|
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
+
tidelift: npm/events
|
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
+
otechie: # Replace with a single Otechie username
|
|
12
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
package/.travis.yml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
dist: xenial
|
|
2
|
+
os: linux
|
|
3
|
+
language: node_js
|
|
4
|
+
node_js:
|
|
5
|
+
- 'stable'
|
|
6
|
+
- 'lts/*'
|
|
7
|
+
- '0.12'
|
|
8
|
+
script:
|
|
9
|
+
- npm test
|
|
10
|
+
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${TRAVIS_NODE_VERSION}" = "stable" ]; then npm run test:browsers; fi
|
|
11
|
+
addons:
|
|
12
|
+
sauce_connect: true
|
|
13
|
+
hosts:
|
|
14
|
+
- airtap.local
|
|
15
|
+
env:
|
|
16
|
+
global:
|
|
17
|
+
- secure: XcBiD8yReflut9q7leKsigDZ0mI3qTKH+QrNVY8DaqlomJOZw8aOrVuX9Jz12l86ZJ41nbxmKnRNkFzcVr9mbP9YaeTb3DpeOBWmvaoSfud9Wnc16VfXtc1FCcwDhSVcSiM3UtnrmFU5cH+Dw1LPh5PbfylYOS/nJxUvG0FFLqI=
|
|
18
|
+
- secure: jNWtEbqhUdQ0xXDHvCYfUbKYeJCi6a7B4LsrcxYCyWWn4NIgncE5x2YbB+FSUUFVYfz0dsn5RKP1oHB99f0laUEo18HBNkrAS/rtyOdVzcpJjbQ6kgSILGjnJD/Ty1B57Rcz3iyev5Y7bLZ6Y1FbDnk/i9/l0faOGz8vTC3Vdkc=
|
package/History.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
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
|
|
52
|
+
for ES5 features. If you need to support older environments, use an ES5 shim
|
|
53
|
+
like [es5-shim](https://npmjs.com/package/es5-shim). Both the shim and sham
|
|
54
|
+
versions 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
|
+
|
|
73
|
+
Note that this version doubles the gzipped size, jumping from 1.1KB to 2.1KB,
|
|
74
|
+
due to new methods and runtime performance improvements. Be aware of that when
|
|
75
|
+
upgrading.
|
|
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
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT
|
|
2
|
+
|
|
3
|
+
Copyright Joyent, Inc. and other Node contributors.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
6
|
+
copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
10
|
+
persons to whom the Software is furnished to do so, subject to the
|
|
11
|
+
following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included
|
|
14
|
+
in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
19
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
20
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
21
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
22
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/Readme.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# events-runtime [](https://travis-ci.org/browserify/events)
|
|
2
|
+
|
|
3
|
+
> Node's event emitter for all engines.
|
|
4
|
+
|
|
5
|
+
This implements the Node.js [`events-runtime`][node.js docs] module for environments that do not have it, like browsers.
|
|
6
|
+
|
|
7
|
+
> `events-runtime` currently matches the **Node.js 11.13.0** API.
|
|
8
|
+
|
|
9
|
+
Note that the `events-runtime` module uses ES5 features. If you need to support very old browsers like IE8, use a shim like [`es5-shim`](https://www.npmjs.com/package/es5-shim). You need both the shim and the sham versions of `es5-shim`.
|
|
10
|
+
|
|
11
|
+
This module is maintained, but only by very few people. If you'd like to help, let us know in the [Maintainer Needed](https://github.com/EVENTS-RUNTIME/events-runtime/issues/43) issue!
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
You usually do not have to install `events-runtime` yourself! If your code runs in Node.js, `events-runtime` is built in. If your code runs in the browser, bundlers like [browserify](https://github.com/EVENTS-RUNTIME/events-runtime) or [webpack](https://github.com/webpack/webpack) also include the `events-runtime` module.
|
|
16
|
+
|
|
17
|
+
But if none of those apply, with npm do:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm install events-runtime
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
var EventEmitter = require('events-runtime')
|
|
27
|
+
|
|
28
|
+
var ee = new EventEmitter()
|
|
29
|
+
ee.on('message', function (text) {
|
|
30
|
+
console.log(text)
|
|
31
|
+
})
|
|
32
|
+
ee.emit('message', 'hello world')
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
See the [Node.js EventEmitter docs][node.js docs]. `events-runtime` currently matches the Node.js 11.13.0 API.
|
|
38
|
+
|
|
39
|
+
## Contributing
|
|
40
|
+
|
|
41
|
+
PRs are very welcome! The main way to contribute to `events-runtime` is by porting features, bugfixes and tests from Node.js. Ideally, code contributions to this module are copy-pasted from Node.js and transpiled to ES5, rather than reimplemented from scratch. Matching the Node.js code as closely as possible makes maintenance simpler when new changes land in Node.js.
|
|
42
|
+
This module intends to provide exactly the same API as Node.js, so features that are not available in the core `events-runtime` module will not be accepted. Feature requests should instead be directed at [nodejs/node](https://github.com/nodejs/node) and will be added to this module once they are implemented in Node.js.
|
|
43
|
+
|
|
44
|
+
If there is a difference in behaviour between Node.js's `events-runtime` module and this module, please open an issue!
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
[MIT](./LICENSE)
|
|
49
|
+
|
|
50
|
+
[node.js docs]: https://nodejs.org/dist/v11.13.0/docs/api/events.html
|