https://github.com/artskydj/make-object-an-emitter
:sparkles: Turns an object into a node emitter.
https://github.com/artskydj/make-object-an-emitter
Last synced: 9 months ago
JSON representation
:sparkles: Turns an object into a node emitter.
- Host: GitHub
- URL: https://github.com/artskydj/make-object-an-emitter
- Owner: ArtskydJ
- Created: 2015-10-13T00:07:47.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-13T00:50:16.000Z (over 10 years ago)
- Last Synced: 2025-01-18T15:53:26.266Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 117 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
make-object-an-emitter
======================
> Turns an object into a node emitter.
[](https://travis-ci.org/ArtskydJ/make-object-an-emitter)
# Example
```js
var makeEmitter = require('make-object-an-emitter')
function myFn () {
console.log('I am a function...')
}
makeEmitter(myFn)
myFn()
myFn.on('event', function () {
console.log('...But I am also an event emitter!!!')
})
```
# API
```js
var makeEmitter = require('make-object-an-emitter')
```
## `makeEmitter(obj)`
`makeEmitter` mutates `obj` (an object/function), that will be turned into an event emitter. Existing properties that don't conflict with event emitter properties will be left on the object.
# License
[MIT](http://opensource.org/licenses/mit)