Comparing version
@@ -62,6 +62,6 @@ // The EventEmitter instance will emit its own 'newListener' | ||
} | ||
listener.apply(events, args); | ||
if (once) { | ||
events.removeListener(eventName, listener); | ||
} | ||
listener.apply(events, args); | ||
}; | ||
@@ -368,3 +368,5 @@ listenerFunction.listener = listener; | ||
// emit "NEW_LISTENER" before added | ||
this.emit(NEW_LISTENER); | ||
if (NEW_LISTENER !== eventName) { | ||
this.emit(NEW_LISTENER, eventName, listener); | ||
} | ||
_events[eventName][prependMethod](createListenerFunction(this, eventName, listener, once)); | ||
@@ -371,0 +373,0 @@ this._checkIfMatchMaxListener(eventName); |
@@ -68,6 +68,6 @@ (function (global, factory) { | ||
} | ||
listener.apply(events, args); | ||
if (once) { | ||
events.removeListener(eventName, listener); | ||
} | ||
listener.apply(events, args); | ||
}; | ||
@@ -374,3 +374,5 @@ listenerFunction.listener = listener; | ||
// emit "NEW_LISTENER" before added | ||
this.emit(NEW_LISTENER); | ||
if (NEW_LISTENER !== eventName) { | ||
this.emit(NEW_LISTENER, eventName, listener); | ||
} | ||
_events[eventName][prependMethod](createListenerFunction(this, eventName, listener, once)); | ||
@@ -377,0 +379,0 @@ this._checkIfMatchMaxListener(eventName); |
@@ -300,3 +300,5 @@ 'use strict'; | ||
// emit "NEW_LISTENER" before added | ||
this.emit(const_1.NEW_LISTENER); | ||
if (const_1.NEW_LISTENER !== eventName) { | ||
this.emit(const_1.NEW_LISTENER, eventName, listener); | ||
} | ||
_events[eventName][prependMethod](utils_1.createListenerFunction(this, eventName, listener, once)); | ||
@@ -303,0 +305,0 @@ this._checkIfMatchMaxListener(eventName); |
@@ -61,6 +61,6 @@ 'use strict'; | ||
} | ||
listener.apply(events, args); | ||
if (once) { | ||
events.removeListener(eventName, listener); | ||
} | ||
listener.apply(events, args); | ||
}; | ||
@@ -67,0 +67,0 @@ listenerFunction.listener = listener; |
{ | ||
"name": "tp-events", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Used to obtain the current events parameters and configuration", | ||
"keywords": [ | ||
"events", | ||
"nodejs events" | ||
"nodejs events", | ||
"EventEmitter" | ||
], | ||
@@ -9,0 +10,0 @@ "main": "dist/events.umd.js", |
@@ -1,8 +0,49 @@ | ||
# event | ||
Nodejs event module in web browser! | ||
# tp-events | ||
[](https://www.travis-ci.org/typescript-practice/events) | ||
[](https://coveralls.io/github/typescript-practice/events?branch=master) | ||
[](https://www.npmjs.com/package/tp-events) | ||
[](https://www.npmjs.com/package/tp-events) | ||
[](https://github.com/prettier/prettier) | ||
[](https://github.com/semantic-release/semantic-release) | ||
[](https://unpkg.com/tp-events@latest/dist/events.umd.js) | ||
[](#/) | ||
将Nodejs中的event模块使用typescript实现一遍. 另外在加上bancemarker | ||
## Intro | ||
Event based JavaScript for the browser with nodejs events api. For more: [Nodejs Events](https://nodejs.org/api/events.html). | ||
## Example | ||
```js | ||
import EventEmitter from 'tp-events' | ||
class MyEmitter extends EventEmitter {} | ||
const myEmitter = new MyEmitter(); | ||
myEmitter.on('event', () => { | ||
console.log('an event occurred!'); | ||
}); | ||
myEmitter.emit('event'); | ||
``` | ||
## Install | ||
[](https://www.npmjs.com/package/tp-events) | ||
## API | ||
Please refer to the document on [Node.js v9.6.1 Events](https://nodejs.org/api/events.html), API is the same. | ||
## Development | ||
- `npm t`: Run test suite | ||
- `npm start`: Run `npm run build` in watch mode | ||
- `npm run test:watch`: Run test suite in [interactive watch mode](http://facebook.github.io/jest/docs/cli.html#watch) | ||
- `npm run test:prod`: Run linting and generate coverage | ||
- `npm run build`: Generate bundles and typings, create docs | ||
- `npm run lint`: Lints code | ||
- `npm run commit`: Commit using conventional commit style ([husky](https://github.com/typicode/husky) will tell you to use it if you haven't :wink:) | ||
## Reference | ||
@@ -12,1 +53,5 @@ | ||
- [Olical EventEmitter](https://github.com/Olical/EventEmitter) | ||
## License | ||
MIT |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2622540
0.43%2774
0.22%57
375%