Comparing version 2.0.0-alpha.6 to 2.0.0-alpha.7
@@ -5,2 +5,9 @@ # Changelog | ||
## [2.0.0-alpha.7](https://github.com/snowyu/events-ex.js/compare/v2.0.0-alpha.6...v2.0.0-alpha.7) (2024-03-20) | ||
### Features | ||
* The listener throw error should not broke the notification, but it will emit error after notification. ([7dce4f6](https://github.com/snowyu/events-ex.js/commit/7dce4f68c516a0169fa4f64f3a5c5277f0c2b743)) | ||
## [2.0.0-alpha.6](https://github.com/snowyu/events-ex.js/compare/v2.0.0-alpha.5...v2.0.0-alpha.6) (2024-03-15) | ||
@@ -7,0 +14,0 @@ |
@@ -29,2 +29,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / [event-emitter](../modules/event_emitter-1.md) / EventEmitter | ||
[src/event-emitter.js:7](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.js#L7) | ||
[src/event-emitter.js:7](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.js#L7) |
@@ -50,3 +50,3 @@ [events-ex](../README.md) / [Exports](../modules.md) / [event-emitter](../modules/event_emitter.md) / EventEmitter | ||
[src/event-emitter.d.ts:7](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L7) | ||
[src/event-emitter.d.ts:7](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L7) | ||
@@ -76,3 +76,3 @@ ## Methods | ||
[src/event-emitter.d.ts:38](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L38) | ||
[src/event-emitter.d.ts:38](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L38) | ||
@@ -102,3 +102,3 @@ ___ | ||
[src/event-emitter.d.ts:44](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L44) | ||
[src/event-emitter.d.ts:44](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L44) | ||
@@ -127,3 +127,3 @@ ___ | ||
[src/event-emitter.d.ts:66](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L66) | ||
[src/event-emitter.d.ts:66](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L66) | ||
@@ -152,3 +152,3 @@ ___ | ||
[src/event-emitter.d.ts:59](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L59) | ||
[src/event-emitter.d.ts:59](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L59) | ||
@@ -182,3 +182,3 @@ ___ | ||
[src/event-emitter.d.ts:32](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L32) | ||
[src/event-emitter.d.ts:32](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L32) | ||
@@ -212,3 +212,3 @@ ___ | ||
[src/event-emitter.d.ts:16](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L16) | ||
[src/event-emitter.d.ts:16](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L16) | ||
@@ -242,3 +242,3 @@ ___ | ||
[src/event-emitter.d.ts:24](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L24) | ||
[src/event-emitter.d.ts:24](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L24) | ||
@@ -267,3 +267,3 @@ ___ | ||
[src/event-emitter.d.ts:51](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L51) | ||
[src/event-emitter.d.ts:51](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L51) | ||
@@ -288,3 +288,3 @@ ___ | ||
[src/event-emitter.d.ts:52](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L52) | ||
[src/event-emitter.d.ts:52](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L52) | ||
@@ -310,2 +310,2 @@ ___ | ||
[src/event-emitter.d.ts:67](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event-emitter.d.ts#L67) | ||
[src/event-emitter.d.ts:67](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event-emitter.d.ts#L67) |
@@ -50,3 +50,3 @@ [events-ex](../README.md) / [Exports](../modules.md) / [event](../modules/event.md) / Event | ||
[src/event.js:8](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event.js#L8) | ||
[src/event.js:8](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event.js#L8) | ||
@@ -63,3 +63,3 @@ ## Properties | ||
[src/event.js:38](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event.js#L38) | ||
[src/event.js:38](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event.js#L38) | ||
@@ -76,3 +76,3 @@ ___ | ||
[src/event.js:32](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event.js#L32) | ||
[src/event.js:32](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event.js#L32) | ||
@@ -89,3 +89,3 @@ ___ | ||
[src/event.js:26](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event.js#L26) | ||
[src/event.js:26](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event.js#L26) | ||
@@ -108,3 +108,3 @@ ## Methods | ||
[src/event.js:45](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event.js#L45) | ||
[src/event.js:45](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event.js#L45) | ||
@@ -131,2 +131,2 @@ ___ | ||
[src/event.js:20](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/event.js#L20) | ||
[src/event.js:20](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/event.js#L20) |
@@ -44,2 +44,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / all-off | ||
[src/all-off.js:12](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/all-off.js#L12) | ||
[src/all-off.js:12](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/all-off.js#L12) |
@@ -28,2 +28,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / consts | ||
[src/consts.js:6](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/consts.js#L6) | ||
[src/consts.js:6](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/consts.js#L6) |
@@ -51,2 +51,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / default-methods | ||
[src/default-methods.js:8](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/default-methods.js#L8) | ||
[src/default-methods.js:8](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/default-methods.js#L8) |
@@ -40,2 +40,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / has-listeners | ||
[src/has-listeners.js:10](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/has-listeners.js#L10) | ||
[src/has-listeners.js:10](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/has-listeners.js#L10) |
@@ -49,2 +49,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / pipe-async | ||
[src/pipe-async.js:21](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/pipe-async.js#L21) | ||
[src/pipe-async.js:21](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/pipe-async.js#L21) |
@@ -49,2 +49,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / pipe | ||
[src/pipe.js:21](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/pipe.js#L21) | ||
[src/pipe.js:21](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/pipe.js#L21) |
@@ -46,2 +46,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / unify | ||
[src/unify.js:17](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/unify.js#L17) | ||
[src/unify.js:17](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/unify.js#L17) |
@@ -39,2 +39,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / util/array-remove | ||
[src/util/array-remove.js:5](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/util/array-remove.js#L5) | ||
[src/util/array-remove.js:5](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/util/array-remove.js#L5) |
@@ -41,2 +41,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / util/object-for-each | ||
[src/util/object-for-each.js:6](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/util/object-for-each.js#L6) | ||
[src/util/object-for-each.js:6](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/util/object-for-each.js#L6) |
@@ -40,2 +40,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / util/string-pad | ||
[src/util/string-pad.js:8](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/util/string-pad.js#L8) | ||
[src/util/string-pad.js:8](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/util/string-pad.js#L8) |
@@ -39,2 +39,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / util/to-int | ||
[src/util/to-int.js:2](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/util/to-int.js#L2) | ||
[src/util/to-int.js:2](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/util/to-int.js#L2) |
@@ -39,2 +39,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / util/valid-callable | ||
[src/util/valid-callable.js:1](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/util/valid-callable.js#L1) | ||
[src/util/valid-callable.js:1](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/util/valid-callable.js#L1) |
@@ -39,2 +39,2 @@ [events-ex](../README.md) / [Exports](../modules.md) / util/valid-object | ||
[src/util/valid-object.js:3](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/util/valid-object.js#L3) | ||
[src/util/valid-object.js:3](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/util/valid-object.js#L3) |
@@ -33,3 +33,3 @@ [events-ex](../README.md) / [Exports](../modules.md) / wrap-event-emitter | ||
[src/wrap-event-emitter.js:6](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/wrap-event-emitter.js#L6) | ||
[src/wrap-event-emitter.js:6](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/wrap-event-emitter.js#L6) | ||
@@ -58,2 +58,2 @@ ## Functions | ||
[src/wrap-event-emitter.js:33](https://github.com/snowyu/events-ex.js/blob/e575b9f/src/wrap-event-emitter.js#L33) | ||
[src/wrap-event-emitter.js:33](https://github.com/snowyu/events-ex.js/blob/7dce4f6/src/wrap-event-emitter.js#L33) |
@@ -35,2 +35,4 @@ events-ex / [Exports](modules.md) | ||
Note: The listener throw error should not broke the notification, but it will emit error(`emit('error', error, 'notify', listener, args)`) after notification. | ||
### Installation | ||
@@ -37,0 +39,0 @@ |
@@ -98,2 +98,3 @@ "use strict"; | ||
const evt = (0, _event.Event)(this); | ||
const errs = []; | ||
try { | ||
@@ -103,8 +104,21 @@ let i = 0; | ||
while (listener = listeners[i]) { | ||
_notify(listener, evt, args); | ||
if (evt.stopped) { | ||
break; | ||
try { | ||
_notify(listener, evt, args); | ||
if (evt.stopped) { | ||
break; | ||
} | ||
} catch (err) { | ||
errs.push({ | ||
err: err, | ||
listener: listener | ||
}); | ||
} | ||
++i; | ||
} | ||
if (errs.length) { | ||
for (let i = 0; i < errs.length; i++) { | ||
const it = errs[i]; | ||
this.emit('error', it.err, 'notify', it.listener, args); | ||
} | ||
} | ||
} finally { | ||
@@ -129,9 +143,23 @@ // eslint-disable-next-line no-unsafe-finally | ||
const evt = (0, _event.Event)(this); | ||
const errs = []; | ||
try { | ||
for (const listener of listeners) { | ||
await _notify(listener, evt, args); | ||
if (evt.stopped) { | ||
break; | ||
try { | ||
await _notify(listener, evt, args); | ||
if (evt.stopped) { | ||
break; | ||
} | ||
} catch (err) { | ||
errs.push({ | ||
err: err, | ||
listener: listener | ||
}); | ||
} | ||
} | ||
if (errs.length) { | ||
for (let i = 0; i < errs.length; i++) { | ||
const it = errs[i]; | ||
this.emit('error', it.err, 'notify', it.listener, args); | ||
} | ||
} | ||
} finally { | ||
@@ -138,0 +166,0 @@ // eslint-disable-next-line no-unsafe-finally |
{ | ||
"name": "events-ex", | ||
"version": "2.0.0-alpha.6", | ||
"version": "2.0.0-alpha.7", | ||
"description": "Browser-friendly enhanced events most compatible with standard node.js, it's powerful eventable ability.", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -43,2 +43,3 @@ ### events-ex [![Build Status](https://img.shields.io/travis/snowyu/events-ex.js/master.png)](http://travis-ci.org/snowyu/events-ex.js) [![npm](https://img.shields.io/npm/v/events-ex.svg)](https://npmjs.org/package/events-ex) [![downloads](https://img.shields.io/npm/dm/events-ex.svg)](https://npmjs.org/package/events-ex) [![license](https://img.shields.io/npm/l/events-ex.svg)](https://npmjs.org/package/events-ex) | ||
注意: 时间内部引发错误不会中断通知,但是会在通知结束时 emit 错误事件(`emit('error', error, 'notify', listener, args)`) | ||
@@ -45,0 +46,0 @@ ### 安装 |
@@ -34,2 +34,3 @@ ### events-ex [![Build Status](https://img.shields.io/travis/snowyu/events-ex.js/master.png)](http://travis-ci.org/snowyu/events-ex.js) [![npm](https://img.shields.io/npm/v/events-ex.svg)](https://npmjs.org/package/events-ex) [![downloads](https://img.shields.io/npm/dm/events-ex.svg)](https://npmjs.org/package/events-ex) [![license](https://img.shields.io/npm/l/events-ex.svg)](https://npmjs.org/package/events-ex) | ||
Note: The listener throw error should not broke the notification, but it will emit error(`emit('error', error, 'notify', listener, args)`) after notification. | ||
@@ -36,0 +37,0 @@ ### Installation |
@@ -95,2 +95,3 @@ import {defineProperty, isArray, isFunction, isNumber, isObject, isUndefined} from 'util-ex' | ||
const evt = Event(this) | ||
const errs = [] | ||
try { | ||
@@ -100,6 +101,16 @@ let i = 0 | ||
while (listener = listeners[i]){ | ||
_notify(listener, evt, args) | ||
if (evt.stopped) {break} | ||
try { | ||
_notify(listener, evt, args) | ||
if (evt.stopped) {break} | ||
} catch(err) { | ||
errs.push({err: err, listener: listener}) | ||
} | ||
++i | ||
} | ||
if (errs.length) { | ||
for (let i=0;i<errs.length;i++) { | ||
const it = errs[i] | ||
this.emit('error', it.err, 'notify', it.listener, args) | ||
} | ||
} | ||
} finally { | ||
@@ -122,7 +133,18 @@ // eslint-disable-next-line no-unsafe-finally | ||
const evt = Event(this) | ||
const errs = [] | ||
try { | ||
for (const listener of listeners) { | ||
await _notify(listener, evt, args); | ||
if (evt.stopped) {break} | ||
try { | ||
await _notify(listener, evt, args); | ||
if (evt.stopped) {break} | ||
} catch(err) { | ||
errs.push({err: err, listener: listener}) | ||
} | ||
} | ||
if (errs.length) { | ||
for (let i=0;i<errs.length;i++) { | ||
const it = errs[i] | ||
this.emit('error', it.err, 'notify', it.listener, args) | ||
} | ||
} | ||
} finally { | ||
@@ -129,0 +151,0 @@ // eslint-disable-next-line no-unsafe-finally |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136941
2152
243