{"_id":"async-event-emitter2","_rev":"2-4281121644b0d119196e5faab12bcc2a","name":"async-event-emitter2","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"async-event-emitter2","version":"0.0.1","keywords":["async","callback","event","eventemitter"],"author":{"name":"Pantelis Georgiadis"},"license":"MIT","_id":"async-event-emitter2@0.0.1","maintainers":[{"name":"pantelisgeorgiadis","email":"PantelisGeorgiadis@Gmail.com"}],"homepage":"https://github.com/PantelisGeorgiadis/async-event-emitter2","bugs":{"url":"https://github.com/PantelisGeorgiadis/async-event-emitter2/issues"},"dist":{"shasum":"395c3c76afe4fbfaeec8034912e40d6aca41336e","tarball":"https://registry.npmjs.org/async-event-emitter2/-/async-event-emitter2-0.0.1.tgz","fileCount":5,"integrity":"sha512-/XemMUiSJKDbPwVkL18l1ngqMZsg4DhJR8KLaxsn3AbYzJtZi/rGR0vU5V2KUw8Hen00M0gnHLR3EeZNpkr4og==","signatures":[{"sig":"MEUCIFxHusKr8bHeh0AIV850/SIlVZYp+pG5HpKDabBOZKHQAiEAttssYEIzld+eORBBAW+evZ2NSc9dvcXxeVX9EBGDys4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26158},"main":"build/async-event-emitter2.min.js","types":"index.d.ts","module":"build/async-event-emitter2.min.js","gitHead":"0050ab2d66dbae7eb59885b8c1b29b63e04f1213","scripts":{"lint":"eslint -c .eslintrc.json --fix src && prettier --config .prettierrc.json --write src/**/*.js test/**/*.js *.ts","test":"mocha test/**/*.test.js","build":"npm run version && npm run lint && npm run test && npm run coverage && npm run webpack","clean":"npm run clean:build && npm run clean:coverage","start":"npm run webpack","version":"node -p -e \"'module.exports = \\'' + require('./package.json').version + '\\';'\" > src/version.js","webpack":"webpack --progress --config webpack.config.js","coverage":"c8 --check-coverage --lines 80 --functions 80 --branches 80 --statements 80 --clean --reporter=text --reporter=html --include=src/*.js --exclude=src/version.js mocha test/**/*.test.js","clean:build":"shx rm -rf build","clean:coverage":"shx rm -rf coverage"},"_npmUser":{"name":"pantelisgeorgiadis","actor":{"name":"pantelisgeorgiadis","type":"user","email":"PantelisGeorgiadis@Gmail.com"},"email":"PantelisGeorgiadis@Gmail.com"},"repository":{"url":"git+https://github.com/PantelisGeorgiadis/async-event-emitter2.git","type":"git"},"_npmVersion":"8.1.2","description":"Just like EventEmitter, but with support for callbacks and interruption of the listener-chain","directories":{},"_nodeVersion":"16.13.1","dependencies":{"async":"^3.2.6"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^9.1.0","chai":"^4.3.10","mocha":"^11.2.2","eslint":"^8.57.0","webpack":"^5.99.8","prettier":"^3.6.2","@types/node":"^24.0.10","webpack-cli":"^6.0.1"},"_npmOperationalInternal":{"tmp":"tmp/async-event-emitter2_0.0.1_1751969723438_0.35947123119498503","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"async-event-emitter2","version":"0.0.2","description":"Just like EventEmitter, but with support for callbacks and interruption of the listener-chain","main":"build/async-event-emitter2.min.js","module":"build/async-event-emitter2.min.js","types":"index.d.ts","scripts":{"build":"npm run version && npm run lint && npm run test && npm run coverage && npm run webpack","clean":"npm run clean:build && npm run clean:coverage","clean:build":"shx rm -rf build","clean:coverage":"shx rm -rf coverage","coverage":"c8 --check-coverage --lines 80 --functions 80 --branches 80 --statements 80 --clean --reporter=text --reporter=html --include=src/*.js --exclude=src/version.js mocha test/**/*.test.js","lint":"eslint -c .eslintrc.json --fix src && prettier --config .prettierrc.json --write src/**/*.js test/**/*.js *.ts","start":"npm run webpack","test":"mocha test/**/*.test.js","version":"node -p -e \"'module.exports = \\'' + require('./package.json').version + '\\';'\" > src/version.js","webpack":"webpack --progress --config webpack.config.js"},"repository":{"type":"git","url":"git+https://github.com/PantelisGeorgiadis/async-event-emitter2.git"},"keywords":["async","callback","event","eventemitter"],"author":{"name":"Pantelis Georgiadis"},"license":"MIT","bugs":{"url":"https://github.com/PantelisGeorgiadis/async-event-emitter2/issues"},"homepage":"https://github.com/PantelisGeorgiadis/async-event-emitter2","dependencies":{"async":"^3.2.6"},"devDependencies":{"@types/node":"^24.0.12","c8":"^9.1.0","chai":"^4.3.10","eslint":"^8.57.0","mocha":"^11.2.2","prettier":"^3.6.2","webpack":"^5.100.0","webpack-cli":"^6.0.1"},"gitHead":"0050ab2d66dbae7eb59885b8c1b29b63e04f1213","_id":"async-event-emitter2@0.0.2","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-STaByrQCwDlQEb1stntYzVYzaS3zA02+3OMm6Ah6hjUWhmmthS0aJaD5t9GGQ/Q8H9vHl8O11PUm9s+z3bNUdQ==","shasum":"fc430b7ee5ef2e39318c7c3f62d224166faac22c","tarball":"https://registry.npmjs.org/async-event-emitter2/-/async-event-emitter2-0.0.2.tgz","fileCount":5,"unpackedSize":26187,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD8StzJ1/Y7suK0/bExQSACSJPUagKBcfEIdU6gQ5GuPAIhAIxbrJ6NHlx59bZCLXeryIzkRWOAgqc79YANFlhEdwYN"}]},"_npmUser":{"name":"pantelisgeorgiadis","email":"PantelisGeorgiadis@Gmail.com","actor":{"name":"pantelisgeorgiadis","email":"PantelisGeorgiadis@Gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"pantelisgeorgiadis","email":"PantelisGeorgiadis@Gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/async-event-emitter2_0.0.2_1752133126280_0.4104819325492155"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-08T10:15:23.438Z","modified":"2025-07-10T07:38:46.698Z","0.0.1":"2025-07-08T10:15:23.599Z","0.0.2":"2025-07-10T07:38:46.509Z"},"bugs":{"url":"https://github.com/PantelisGeorgiadis/async-event-emitter2/issues"},"author":{"name":"Pantelis Georgiadis"},"license":"MIT","homepage":"https://github.com/PantelisGeorgiadis/async-event-emitter2","keywords":["async","callback","event","eventemitter"],"repository":{"type":"git","url":"git+https://github.com/PantelisGeorgiadis/async-event-emitter2.git"},"description":"Just like EventEmitter, but with support for callbacks and interruption of the listener-chain","maintainers":[{"name":"pantelisgeorgiadis","email":"PantelisGeorgiadis@Gmail.com"}],"readme":"[![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![build][build-image]][build-url] [![MIT License][license-image]][license-url] \r\n\r\n# async-event-emitter2\r\n\r\nThe original [async-eventemitter][async-eventemitter-url] package by [Andreas Hultgren][ahultgren-url] wasn't updated for several years now and this is an effort to support newer versions. Below is the original README: \r\n\r\n> An EventEmitter that supports serial execution of asynchronous event listeners. It also supports event listeners without callbacks (synchronous), as well as interrupting the call-chain (similar to the DOM's e.stopPropagation()).\r\n\r\n## Example\r\n```js\r\nconst AsyncEventEmitter2 = require('async-event-emitter2');\r\nconst events = new AsyncEventEmitter2();\r\n\r\nevents.on('test', (e, next) => {\r\n  // The next event listener will wait till this is done\r\n  setTimeout(next, 1000);\r\n});\r\n\r\nevents\r\n  .on('test', (e) => {\r\n    // This is a synchronous event listener (note the lack of a second callback argument)\r\n    console.log(e);\r\n    // { data: 'data' }\r\n  })\r\n  .on('test', (e, next) => {\r\n    // Even if this is not truly asynchronous, next() can be used to stop propagation\r\n    next(new Error('You shall not pass'));\r\n  });\r\n\r\nevents.emit('test', { data: 'data' }, (err) => {\r\n  // This runs after all event listeners are done\r\n  console.log(err);\r\n  // [Error: You shall not pass]\r\n});\r\n```\r\nMore examples are found in the `test`-folder.\r\n\r\n## Important differences between AsyncEventEmitter the native EventEmitter\r\nThe API and behavior of AsyncEventEmitter is as far as possible and meaningful identical to that of the native EventEmitter. However there are some important differences which should be noted.\r\n\r\n* Data sent to event listeners (`e.g. emit(data)`) must always be **zero** or **one** argument, and can *not* be a function.\r\n* Event listeners will always receive the data object, which may or may not be undefined.\r\n* The second argument can only be a callback, and will only be supplied if the event listener has an arity of two or more (e.g. `(e, next) => { }`).\r\n* Event listeners with an arity of one or zero (e.g. without a callback argument specified) will be treated as synchronous.\r\n* Even if all event listeners are synchronous, they will still be executed asynchronously (through setImmediate) and thus code succeeding `.emit()` will be executed before any event listeners.\r\n* Interrupt the callback chain in async listeners by calling the callback with the error as the first parameter; in sync listeners by throwing an Error.\r\n\r\n## Usage\r\n### Unchanged\r\nFor `addListener() on() once() removeListener() removeAllListeners() setMaxListeners() listeners()` see the [EventEmitter docs][eventemitter-url], nothing new here.\r\n\r\n### `emit(event, [data], [callback])`\r\nExecutes all listeners for the event in order with the supplied data argument. The optional callback is called when all of the listeners are done.\r\n\r\n### `.first(event, new)`\r\nAdds a listener to the beginning of the listeners array for the specified event.\r\n\r\n### `.at(event, index, listener)`\r\nAdds a listener at the specified index in the listeners array for the specified event.\r\n\r\n### `.before(event, target, listener)`\r\nAdds a listener before the target listener in the listeners array for the specified event.\r\n\r\n### `.after(event, target, listener)`\r\nAdds a listener after the target listener in the listeners array for the specified event.\r\n\r\n## Contribution\r\n1. Create an issue and tell me what you're gonna do, just to make sure there's no duplicate work.\r\n2. Fork and branch your feature-branch of the develop branch.\r\n3. Write tests for changed/added functionality and make sure you don't break existing ones.\r\n4. Adhere to existing code style.\r\n5. Submit a pull-request to the develop branch.\r\n\r\n## License\r\nasync-event-emitter2 is released under the MIT License.\r\n\r\n[npm-url]: https://npmjs.org/package/async-event-emitter2\r\n[npm-version-image]: https://img.shields.io/npm/v/async-event-emitter2.svg?style=flat\r\n[npm-downloads-image]: http://img.shields.io/npm/dm/async-event-emitter2.svg?style=flat\r\n\r\n[build-url]: https://github.com/PantelisGeorgiadis/async-event-emitter2/actions/workflows/build.yml\r\n[build-image]: https://github.com/PantelisGeorgiadis/async-event-emitter2/actions/workflows/build.yml/badge.svg?branch=master\r\n\r\n[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat\r\n[license-url]: LICENSE.txt\r\n\r\n[async-eventemitter-url]: https://github.com/ahultgren/async-eventemitter\r\n[ahultgren-url]: https://github.com/ahultgren\r\n[eventemitter-url]: http://nodejs.org/api/events.html\r\n","readmeFilename":"README.md"}