{"_id":"component-emitter","_rev":"3184264","name":"component-emitter","description":"Simple event emitter","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2023-12-06T08:50:01.000Z","created":"2014-02-11T02:15:29.076Z","2.0.0":"2023-11-17T09:55:09.525Z","1.3.1":"2023-11-16T20:57:12.372Z","1.3.0":"2019-04-15T20:48:08.367Z","1.2.1":"2016-04-18T18:55:09.978Z","1.2.0":"2015-02-12T18:37:13.945Z","1.1.3":"2014-06-20T06:24:49.737Z","1.1.2":"2014-02-11T02:15:29.076Z"},"users":{"h02e56":true,"kontrax":true,"tommyzzm":true,"antixrist":true,"monjer":true,"alexsasharegan":true,"dwqs":true,"heartnett":true},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/component-emitter.git"},"versions":{"2.0.0":{"name":"component-emitter","version":"2.0.0","description":"Simple event emitter","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/component-emitter.git"},"funding":"https://github.com/sponsors/sindresorhus","exports":{"types":"./index.d.ts","default":"./index.js"},"main":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava"},"keywords":["event","emitter","events","emit","listener","pubsub","observe"],"devDependencies":{"ava":"^5.3.1","xo":"^0.56.0"},"xo":{"rules":{"unicorn/prefer-module":"off"}},"gitHead":"cfa15e8a6382f4403fb8b05f9c363ae997eb171c","bugs":{"url":"https://github.com/sindresorhus/component-emitter/issues"},"homepage":"https://github.com/sindresorhus/component-emitter#readme","_id":"component-emitter@2.0.0","_nodeVersion":"20.9.0","_npmVersion":"9.2.0","dist":{"shasum":"3a137dfe66fcf2efe3eab7cb7d5f51741b3620c6","size":3004,"noattachment":false,"key":"/component-emitter/-/component-emitter-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/component-emitter/download/component-emitter-2.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/component-emitter_2.0.0_1700214909279_0.06708946606374044"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-17T09:55:09.525Z","publish_time":1700214909525,"_source_registry_name":"default","_cnpm_publish_time":1700214909525},"1.3.1":{"name":"component-emitter","description":"Event emitter","version":"1.3.1","license":"MIT","funding":"https://github.com/sponsors/sindresorhus","devDependencies":{"mocha":"*","should":"*"},"component":{"scripts":{"emitter/index.js":"index.js"}},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/sindresorhus/component-emitter.git"},"scripts":{"test":"make test"},"gitHead":"6bd7817e8a444cb16e8abdf7dd2d7f04d5ca3dc8","bugs":{"url":"https://github.com/sindresorhus/component-emitter/issues"},"homepage":"https://github.com/sindresorhus/component-emitter#readme","_id":"component-emitter@1.3.1","_nodeVersion":"20.9.0","_npmVersion":"9.2.0","dist":{"shasum":"ef1d5796f7d93f135ee6fb684340b26403c97d17","size":2517,"noattachment":false,"key":"/component-emitter/-/component-emitter-1.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/component-emitter/download/component-emitter-1.3.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/component-emitter_1.3.1_1700168232172_0.06998589414312195"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-16T20:57:12.372Z","publish_time":1700168232372,"_source_registry_name":"default","_cnpm_publish_time":1700168232372},"1.3.0":{"name":"component-emitter","description":"Event emitter","version":"1.3.0","license":"MIT","devDependencies":{"mocha":"*","should":"*"},"component":{"scripts":{"emitter/index.js":"index.js"}},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/component/emitter.git"},"scripts":{"test":"make test"},"gitHead":"6bd7817e8a444cb16e8abdf7dd2d7f04d5ca3dc8","bugs":{"url":"https://github.com/component/emitter/issues"},"homepage":"https://github.com/component/emitter#readme","_id":"component-emitter@1.3.0","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"nami-doc","email":"vendethiel@hotmail.fr"},"dist":{"shasum":"16e4070fba8ae29b679f2215853ee181ab2eabc0","size":3102,"noattachment":false,"key":"/component-emitter/-/component-emitter-1.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/component-emitter/download/component-emitter-1.3.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/component-emitter_1.3.0_1555361288195_0.12626268851479416"},"_hasShrinkwrap":false,"publish_time":1555361288367,"_cnpm_publish_time":1555361288367},"1.2.1":{"name":"component-emitter","description":"Event emitter","version":"1.2.1","license":"MIT","devDependencies":{"mocha":"*","should":"*"},"component":{"scripts":{"emitter/index.js":"index.js"}},"main":"index.js","repository":{"type":"git","url":"git+https://github.com/component/emitter.git"},"scripts":{"test":"make test"},"files":["index.js","LICENSE"],"gitHead":"187492ab8028c7221b589bdfd482b715149cd868","bugs":{"url":"https://github.com/component/emitter/issues"},"homepage":"https://github.com/component/emitter#readme","_id":"component-emitter@1.2.1","_shasum":"137918d6d78283f7df7a6b7c5a63e140e69425e6","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"nami-doc","email":"karp@hotmail.fr"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"137918d6d78283f7df7a6b7c5a63e140e69425e6","size":2964,"noattachment":false,"key":"/component-emitter/-/component-emitter-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/component-emitter/download/component-emitter-1.2.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/component-emitter-1.2.1.tgz_1461005707641_0.14232611074112356"},"directories":{},"publish_time":1461005709978,"_cnpm_publish_time":1461005709978,"_hasShrinkwrap":false},"1.2.0":{"name":"component-emitter","description":"Event emitter","version":"1.2.0","license":"MIT","devDependencies":{"mocha":"*","should":"*"},"component":{"scripts":{"emitter/index.js":"index.js"}},"main":"index.js","repository":{"type":"git","url":"https://github.com/component/emitter.git"},"scripts":{"test":"make test"},"files":["index.js","LICENSE"],"gitHead":"4d18307a2cdd2cec16d1fadf9e04f02351a8d62e","bugs":{"url":"https://github.com/component/emitter/issues"},"homepage":"https://github.com/component/emitter","_id":"component-emitter@1.2.0","_shasum":"ccd113a86388d06482d03de3fc7df98526ba8efe","_from":".","_npmVersion":"2.5.1","_nodeVersion":"1.2.0","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"ccd113a86388d06482d03de3fc7df98526ba8efe","size":2873,"noattachment":false,"key":"/component-emitter/-/component-emitter-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/component-emitter/download/component-emitter-1.2.0.tgz"},"directories":{},"publish_time":1423766233945,"_cnpm_publish_time":1423766233945,"_hasShrinkwrap":false},"1.1.3":{"name":"component-emitter","description":"Event emitter","version":"1.1.3","devDependencies":{"mocha":"*","should":"*"},"component":{"scripts":{"emitter/index.js":"index.js"}},"main":"index.js","repository":{"type":"git","url":"https://github.com/component/emitter.git"},"scripts":{"test":"make test"},"bugs":{"url":"https://github.com/component/emitter/issues"},"homepage":"https://github.com/component/emitter","_id":"component-emitter@1.1.3","_shasum":"2bf887a4a9fc856eafcabcd82a43eb42a57eec6f","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"juliangruber","email":"julian@juliangruber.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"2bf887a4a9fc856eafcabcd82a43eb42a57eec6f","size":3177,"noattachment":false,"key":"/component-emitter/-/component-emitter-1.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/component-emitter/download/component-emitter-1.1.3.tgz"},"directories":{},"publish_time":1403245489737,"_cnpm_publish_time":1403245489737,"_hasShrinkwrap":false},"1.1.2":{"name":"component-emitter","description":"Event emitter","version":"1.1.2","devDependencies":{"mocha":"*","should":"*"},"component":{"scripts":{"emitter/index.js":"index.js"}},"main":"index.js","repository":{"type":"git","url":"https://github.com/component/emitter.git"},"scripts":{"test":"make test"},"bugs":{"url":"https://github.com/component/emitter/issues"},"homepage":"https://github.com/component/emitter","_id":"component-emitter@1.1.2","dist":{"shasum":"296594f2753daa63996d2af08d15a95116c9aec3","size":2474,"noattachment":false,"key":"/component-emitter/-/component-emitter-1.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/component-emitter/download/component-emitter-1.1.2.tgz"},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"tootallnate","email":"nathan@tootallnate.net"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1392084929076,"_cnpm_publish_time":1392084929076,"_hasShrinkwrap":false}},"readme":"# component-emitter\n\n> Simple event emitter\n\n## Install\n\n```sh\nnpm install component-emitter\n```\n\n## Usage\n\nAs an `Emitter` instance:\n\n```js\nimport Emitter from 'component-emitter';\n\nconst emitter = new Emitter();\n\nemitter.emit('????');\n```\n\nAs a mixin:\n\n```js\nimport Emitter from 'component-emitter';\n\nconst user = {name: 'tobi'};\nEmitter(user);\n\nuser.emit('I am a user');\n```\n\nAs a prototype mixin:\n\n```js\nimport Emitter from 'component-emitter';\n\nEmitter(User.prototype);\n```\n\n## API\n\n### new Emitter()\n\nCreate a new emitter.\n\n### Emitter(object)\n\nUse it as a mixin. For example a plain object may become an emitter, or you may extend an existing prototype.\n\n### Emitter#on(event, listener)\n\nRegister an event handler that listens to a specified event.\n\n### Emitter#once(event, listener)\n\nRegister a one-time event handler for a specified event.\n\n### Emitter#off(event, listener)\n\nRemove a specific event handler for a specified event.\n\n### Emitter#off(event)\n\nRemove all event handlers for a specified event.\n\n### Emitter#off()\n\nRemove all event handlers for all events.\n\n### Emitter#emit(event, ...arguments)\n\nEmit an event, invoking all handlers registered for it.\n\n### Emitter#listeners(event)\n\nRetrieve the event handlers registered for a specific event.\n\n### Emitter#listenerCount(event)\n\nGet the count of listeners for a specific event.\n\n### Emitter#listenerCount()\n\nGet the count of all event handlers in total.\n\n### Emitter#hasListeners(event)\n\nCheck if there are any handlers registered for a specific event.\n\n### Emitter#hasListeners()\n\nCheck if there are any handlers registered for any event.\n\n## FAQ\n\n### How does it differ from the Node.js EventEmitter?\n\nIt's simpler and more lightweight, and it works in any JavaScript environment, not just Node.js. It also provides mixin functionality to add event handling to existing objects without needing inheritance.\n","_attachments":{},"homepage":"https://github.com/sindresorhus/component-emitter#readme","bugs":{"url":"https://github.com/sindresorhus/component-emitter/issues"},"license":"MIT"}