{"_id":"@botdev-univ/events","_rev":"2-860e9ba75b9bf3a5382a1b2fdbab7645","name":"@botdev-univ/events","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@botdev-univ/events","version":"1.0.0","description":"A simple and lightweight EventEmitter for node.js or browsers.","type":"module","source":"./src/index.ts","main":"./dist/index.cjs","umd:main":"./dist/index.umd.cjs","module":"./dist/index.js","exports":{"require":"./dist/index.cjs","default":"./dist/index.modern.js"},"types":"./dist/index.d.ts","scripts":{"prepublish":"npm run lint && npm run build","lint":"eslint \"./src/**/*.ts\"","build":"rm -rf dist && microbundle build --no-sourcemap --no-compress --tsconfig tsconfig.json"},"repository":{"type":"git","url":"git+https://github.com/botdev-univ/events.git"},"keywords":["eventemitter","events","event","emitter","listener","emitters","browser","nodejs"],"author":{"name":"arugaz","email":"arugaastri@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/botdev-univ/events/issues"},"homepage":"https://github.com/botdev-univ/events#readme","devDependencies":{"@typescript-eslint/eslint-plugin":"^5.0.0","eslint":"^8.0.1","eslint-config-standard-with-typescript":"^34.0.0","eslint-plugin-import":"^2.25.2","eslint-plugin-n":"^15.0.0","eslint-plugin-promise":"^6.0.0","microbundle":"^0.15.0","typescript":"^4.9.0"},"gitHead":"e5b68d88acf7517d9b50884e7cdf30a1b4d2afe8","_id":"@botdev-univ/events@1.0.0","_nodeVersion":"16.19.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-AJbNgQ/C2Khx7XProfzs209PI0Aq9awF7xPs7zjsahg6L5ScXQ9j4l0zacrbnN/QxtKZ1I3moPHODNfMCar6Tw==","shasum":"242f83b3ed86d1330c6ac6cfde4392dbfcd0db0e","tarball":"https://registry.npmjs.org/@botdev-univ/events/-/events-1.0.0.tgz","fileCount":10,"unpackedSize":43600,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG6M5HlSUzVPmzaXUTIMpsEvGnYWset/s1PGIgXkM5AUAiBZwiepWmjwG4hRlXwsqNJfZKrQluYjT7q5S9dcYwrgCQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj6L+BACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo2Rw//S42CoCL9DgGfPODfCTbP0mP7Pky0g24qGoFC3x9aDzsP2f+d\r\nmTwQOP97oautv344TE+2QSKXPcEX1NRFmR++luCMAi+Wv1RxdHxxgSnM3TZf\r\nvXLoJpY41GN9gLBt6SueimJnIa6Xca+8kT+xpE1ToFa3xAu+eTWNnFGArQPU\r\nPpQ0AM8teVsqihGRxBTSV45eYVrHphZdrlqodUVoxsUqp0phDcq7eIulT1E8\r\nzoMUgjAaSC6JFxyWYV2TtshqHzbyTS/EBl162OM5oyrhGzVvtYx5jw3lH2G8\r\nXzmKOGK1EuMtcbZFyGY/U6Q3u03NJjZByMmc5imMdmfNXu3wkvTO431GtbnA\r\nvvs4ds8xsD8LRq/HTgyqVp/N1sLOkg7xYdm9ZlFPq/alLnVYg3H23KUqOLcR\r\nFrO9KD3Qy7geizwIoEWL01BgMxf0DWLeh4YlWk3aNrpd/e1jGt7HiCcEKUnN\r\nlCqz3LWaO7S897J4dMwgRJt2ZbzIN9a03s1Zoa40IzKfe7IfLWaibMNkGbaL\r\nJ+R62UdnvmQK1lgAWtYrj9I0PCJGm7FsAxeHC+oqUwOUUnWDSNgc8Vb/E7Y4\r\nKX1UP3XSra30/nv72FYRx65CYzNLwGK8qjaz1UEC+GKjdcdbUpO9DRKvZs4B\r\nWfJFGlo3HVvPInLihRdeJi+LJla6Gg40yXI=\r\n=pHVz\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"arugaz","email":"arugaastri@Gmail.com"},"directories":{},"maintainers":[{"name":"arugaz","email":"arugaastri@Gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/events_1.0.0_1676197761768_0.7597475338261996"},"_hasShrinkwrap":false},"1.0.1":{"name":"@botdev-univ/events","version":"1.0.1","description":"A simple and lightweight EventEmitter for node.js or browsers.","type":"module","source":"./src/index.ts","main":"./dist/index.cjs","umd:main":"./dist/index.umd.cjs","module":"./dist/index.js","exports":{"require":"./dist/index.cjs","default":"./dist/index.modern.js"},"types":"./dist/index.d.ts","scripts":{"prepublish":"npm run lint && npm run build","lint":"eslint \"./src/**/*.ts\"","build":"rm -rf dist && microbundle build --no-sourcemap --no-compress --tsconfig tsconfig.json"},"repository":{"type":"git","url":"git+https://github.com/botdev-univ/events.git"},"keywords":["eventemitter","events","event","emitter","listener","emitters","browser","nodejs"],"author":{"name":"arugaz","email":"arugaastri@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/botdev-univ/events/issues"},"homepage":"https://github.com/botdev-univ/events#readme","devDependencies":{"@typescript-eslint/eslint-plugin":"^5.0.0","eslint":"^8.0.1","eslint-config-standard-with-typescript":"^34.0.0","eslint-plugin-import":"^2.25.2","eslint-plugin-n":"^15.0.0","eslint-plugin-promise":"^6.0.0","microbundle":"^0.15.0","typescript":"^4.9.0"},"gitHead":"cb60cfd901dd9154f47f51f8c6b73d89e36277a6","_id":"@botdev-univ/events@1.0.1","_nodeVersion":"16.19.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-c5am3wCrozYlxrQihEINypDmo8mbC8sIE2dMereovuWQ8q0Xo72LjmvZ7L0fgBv3G+yEsE063HJADJuRofOKfQ==","shasum":"1386df9e8849ff8d985fca70eaffdb17af34d9b9","tarball":"https://registry.npmjs.org/@botdev-univ/events/-/events-1.0.1.tgz","fileCount":10,"unpackedSize":45906,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFUMxztVEkIPjazOh5XV9z+rtQoVRW33xpMPynGu/1uwAiEA1RjYhvciZU86Zbi+DvKYhEM1FjFP9f6O/BN2WxK2Z5Y="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj6MdNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoLPw/+Ji3mmUiIS615ZeURIwtPMYX9AbJvtkFtK7sy6DPfKTkftNlc\r\n9ROVMvfFooqVs9zo76IyGoJxvzqg/B5whxNNTx96pyDx7fQqYwfeVhWQqm5e\r\nL9WJVnB4G+pvsDAIgMiUdoHaKZSKrzsocYX0p86q8k2JR5DzS8d+qlz9wLQY\r\nbXoNuEKRuxOE7csN2yozidp9VslfSE/LBlMYM2jzOe/jt+bV1bjmiSLqfcf9\r\nwY9JmcWzuVHWYcOWtLEaJ873Cc+edPoG6K94qFEMfB8IOiUwGIF6tw7seS3x\r\nzEDKRMq62Z+1QIpNnJxKM65/PXOMCssmL05i8Zlfkqd2edkVhOIN2Zq85fW7\r\nJPLdUq62HseeT1MBQAT0DspVnB7L6TiUM+YvQ1xQwUkFTAZtZQQumX+n9lqu\r\np626WEqdLAbNk8u3ccWh2drXQorOalE2uYn8415MBXUrlhbbx7jN9tthgkfA\r\n3ynpfpyc2TnAdDrnwGGy0vw+Nmpxe19W6gkjgkpyKeDqmSJr39I4QJWsNTOH\r\nTeGEwPJ2xh7Kz+NEk/Vor5qbo4xE/Plp/YsYGxBYDH+MKRJ691SUy4V4UrnT\r\nku8EMnYcMFGb1eqEWrmg35nIa0h7Cq2hccywDYvjfLcJY2c2m/DS/3+FyIPi\r\nuSdqpzfaJJs5bZ1z/34H4xoghpoZLoGlcok=\r\n=04Xh\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"arugaz","email":"arugaastri@Gmail.com"},"directories":{},"maintainers":[{"name":"arugaz","email":"arugaastri@Gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/events_1.0.1_1676199757185_0.37782816389224916"},"_hasShrinkwrap":false},"1.0.2":{"name":"@botdev-univ/events","version":"1.0.2","description":"A simple and lightweight EventEmitter for node.js or browsers.","type":"module","source":"./src/index.ts","main":"./dist/index.cjs","umd:main":"./dist/index.umd.cjs","module":"./dist/index.js","exports":{"require":"./dist/index.cjs","default":"./dist/index.modern.js"},"types":"./dist/index.d.ts","scripts":{"prepublish":"npm run lint && npm run build","lint":"eslint \"./src/**/*.ts\"","build":"rm -rf dist && microbundle build --no-sourcemap --no-compress --tsconfig tsconfig.json"},"repository":{"type":"git","url":"git+https://github.com/botdev-univ/events.git"},"keywords":["eventemitter","events","event","emitter","listener","emitters","browser","nodejs"],"author":{"name":"arugaz","email":"arugaastri@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/botdev-univ/events/issues"},"homepage":"https://github.com/botdev-univ/events#readme","devDependencies":{"@typescript-eslint/eslint-plugin":"^5.0.0","eslint":"^8.0.1","eslint-config-standard-with-typescript":"^34.0.0","eslint-plugin-import":"^2.25.2","eslint-plugin-n":"^15.0.0","eslint-plugin-promise":"^6.0.0","microbundle":"^0.15.0","typescript":"^4.9.0"},"gitHead":"676a7f2e8c99a74e552084c138d19d7576433a7c","_id":"@botdev-univ/events@1.0.2","_nodeVersion":"16.19.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-BOl20qzxcC9ykHuV5pmhoNV823MXfjJx/AlQdfMERTz4K87vBpxlvzhnx4tS7UCmJWnq1szyuZdGZoXmkXTKIQ==","shasum":"de601ed2c2fe3e2c81d2184292e96f5c318593dc","tarball":"https://registry.npmjs.org/@botdev-univ/events/-/events-1.0.2.tgz","fileCount":10,"unpackedSize":45870,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDvLjG2f2g63uMYZ2dtEMBaRM1rozebixcoyRuPlWfmzQIhAJh13DDnG6fRH8NV/6Ulzv/AoFjDSwOzpCvT19U2hBan"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj6Mr+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp/hg/+MpbyJ88zUjadEdBXZE+/6xjOHneUCIjY6Ce/Pxak2zXUNjOX\r\nRZmpMIFt6CKLj8deifidEDdTEKW/3pAUFtruixQCgHV/EWAv0JeaHWB9nY1C\r\ndbXkDy3DnEotVCBs5E2WI5oOl0RqUiQlzpN444V3chx8mLIeYiW5fUwzmwxJ\r\nrIfdVJuNzXA87YzGKSIxX/S4ZYCuDN1LGKaofDzr2d8EzuNbTdmsMQKLnEv1\r\nxf6GEdeqyLzBghjKzL8deGymJRkm6mmb85/jdTur1yN3FZJPH4nSUOkbdXPH\r\nclPZYzBLn3ciznbAwoOR18C7UufOtIesOP1yfgZa7vTji1DO4h5+6+9aXsh0\r\nNJIDxbhA2ABU+EwzBObLN14sNhWRAuVrHClsMbRKVD/6+Eub4wnDi4TdVxgE\r\nd6YQVbt99RF3u7APmXgpLIuqIA5Slp4dfCFRUf1G/cyVQpSOK5i8r+QmWQUG\r\nN2sA3MYXO7oCv6P0oPMUFIzNMeONQTmkqkLrZMjI8NrJwl/nMix4cVhAV4SZ\r\nYacEFwVThjwpVfimA+aXdOJcMnL1gBKeYoazUJTM273jn/jstP41PI5LX9vY\r\nkL14WtEMxHdURBsTF75q01Sfgh+bY1HKqj8YWroqWcqXMx/Kqz1y7/0ISWNx\r\nqWDl3a0Mi4ljz0x0Y2v51sh943WeR7MSUss=\r\n=RfMS\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"arugaz","email":"arugaastri@Gmail.com"},"directories":{},"maintainers":[{"name":"arugaz","email":"arugaastri@Gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/events_1.0.2_1676200701865_0.41329693126662015"},"_hasShrinkwrap":false}},"time":{"created":"2023-02-12T10:29:21.708Z","1.0.0":"2023-02-12T10:29:21.946Z","modified":"2023-02-12T11:18:22.130Z","1.0.1":"2023-02-12T11:02:37.372Z","1.0.2":"2023-02-12T11:18:22.041Z"},"maintainers":[{"name":"arugaz","email":"arugaastri@Gmail.com"}],"description":"A simple and lightweight EventEmitter for node.js or browsers.","homepage":"https://github.com/botdev-univ/events#readme","keywords":["eventemitter","events","event","emitter","listener","emitters","browser","nodejs"],"repository":{"type":"git","url":"git+https://github.com/botdev-univ/events.git"},"author":{"name":"arugaz","email":"arugaastri@gmail.com"},"bugs":{"url":"https://github.com/botdev-univ/events/issues"},"license":"MIT","readme":"# Events\n\nA simple and lightweight EventEmitter library for node.js or browsers.\n\n## Install\n\nInstall the dependency\n\n```shell\nnpm install @botdev-univ/events\nyarn add @botdev-univ/events\n```\n\n## Overview\n\n- [EventEmitter](#eventemitter)\n- [on / addListener](#on)\n- [once](#once)\n- [off / removeListener](#off)\n- [emit](#emit)\n- [EventHandler](#eventhandler)\n- [Event](#event)\n\n## API\n\n### EventEmitter\n\nIt's a class for managing events. It can be extended to provide event functionality for other classes or object.\n\n- **class** - ES6 Class\n\nThere have two ways to use it.\n\nOne way:\n\n```typescript\nimport EventEmitter from '@botdev-univ/events';\n\nconst emitter = new EventEmitter();\nemitter.on('event', evt => {\n  console.log(evt);\n});\n```\n\nAnother way:\n\n```typescript\nclass Store extends EventEmitter {\n  set(key: string, value: any) {\n    this.emit(`change:${key}`, value);\n  }\n}\n```\n\n### on\n\nListen on a new event by type and handler. If listen on, the true is returned, otherwise the false.\nThe handler will not be listen if it is a duplicate.\n\n- **type** (`string`) - event type, it must be a unique string.\n- **handler** ([EventHandler](#eventhandler)) - event handler, when if the same handler is passed, listen it by only once.\n- **return** (`boolean`) If listen on, the true is returned, otherwise the false.\n\n```typescript\nconst emitter = new EventEmitter();\nemitter.on('event', evt => {\n  console.log(evt);\n});\n```\n\n### once\n\nListen on an once event by type and handler. When the event is fired, that will be listen off immediately and automatically.\nThe handler will not be listen if it is a duplicate.\n\n- **type** (`string`) - event type, it must be a unique string.\n- **handler** ([EventHandler](#eventhandler)) - event handler, when if the same handler is passed, listened by only once.\n- **return** (`boolean`) If listened on, the true is returned, otherwise the false.\n\n```typescript\nconst emitter = new EventEmitter();\nemitter.once('event', evt => {\n  console.log(evt);\n});\n```\n\n### off\n\nListen off an event by type and handler.\nOr listen off events by type, when if only type argument is passed.\nOr listen off all events, when if no arguments are passed.\n\n- _**[type]**_ (`string` `optional`) event type\n- _**[handler]**_ ([EventHandler](#eventhandler) `optional`) event handler\n\nListen off the specified event.\n\n```typescript\nconst emitter = new EventEmitter();\nemitter.off('event', evt => undefined);\n```\n\nListen off events by type.\n\n```typescript\nconst emitter = new EventEmitter();\nemitter.off('event');\n```\n\nListen off all events, it does samething as `offAll` method.\n\n```typescript\nconst emitter = new EventEmitter();\nemitter.off();\n```\n\n### emit\n\nEmit the specified event, and you can to pass a data. When emitted, every handler attached to that event will be executed.\nBut, if it's an once event, listen off it immediately after called handler.\n\n- **type** (`string`) - event type\n- _**[data]**_ (`any`) - event data\n\n```typescript\nconst emitter = new EventEmitter();\nemitter.emit('event', 'test data');\n```\n\n### EventHandler\n\nThe event handler, that is a normal function.\n\n- **evt** ([Event](#event)) - event object, that will be pass to event handler as it argument.\n\n### Event\n\nEvent object.\n\n- **type** (`string`) - event type\n- **data** (`any`) - event data\n- **timestamp** (`number`) - the timestamp when event emitted\n- **once** (`boolean`) - it is an once event, that meaning listen off after event fired\n\n## License\n\n[MIT License](LICENSE)","readmeFilename":"README.md"}