bare-events 2.4.1 → 2.5.0

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.
Files changed (2) hide show
  1. package/index.js +10 -4
  2. package/package.json +10 -3
package/index.js CHANGED
@@ -171,6 +171,8 @@ module.exports = exports = class EventEmitter {
171
171
 
172
172
  exports.EventEmitter = exports
173
173
 
174
+ exports.errors = errors
175
+
174
176
  exports.defaultMaxListeners = 10
175
177
 
176
178
  exports.on = function on (emitter, name, opts = {}) {
@@ -270,11 +272,11 @@ exports.once = function once (emitter, name, opts = {}) {
270
272
  signal
271
273
  } = opts
272
274
 
273
- return new Promise((resolve, reject) => {
274
- if (signal && signal.aborted) {
275
- return reject(errors.OPERATION_ABORTED(signal.reason))
276
- }
275
+ if (signal && signal.aborted) {
276
+ throw errors.OPERATION_ABORTED(signal.reason)
277
+ }
277
278
 
279
+ return new Promise((resolve, reject) => {
278
280
  if (name !== 'error') emitter.on('error', onerror)
279
281
 
280
282
  if (signal) signal.addEventListener('abort', onabort)
@@ -328,3 +330,7 @@ exports.forward = function forward (from, to, names, opts = {}) {
328
330
  }
329
331
  })
330
332
  }
333
+
334
+ exports.listenerCount = function listenerCount (emitter, name) {
335
+ return emitter.listenerCount(name)
336
+ }
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "bare-events",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "Event emitters for JavaScript",
5
- "main": "index.js",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./package": "./package.json",
8
+ "./errors": "./lib/errors.js"
9
+ },
6
10
  "files": [
7
11
  "index.js",
8
12
  "lib"
9
13
  ],
10
14
  "scripts": {
11
- "test": "standard && bare test.js"
15
+ "test": "npm run lint && npm run test:bare && npm run test:node",
16
+ "test:bare": "bare test.js",
17
+ "test:node": "node test.js",
18
+ "lint": "standard"
12
19
  },
13
20
  "repository": {
14
21
  "type": "git",