{"_id":"@deot/helper-emitter","_rev":"3-4ffacdb44eb477bca1cc317414be26d8","name":"@deot/helper-emitter","dist-tags":{"latest":"1.1.3"},"versions":{"1.0.1":{"name":"@deot/helper-emitter","version":"1.0.1","main":"dist/index.cjs.js","module":"dist/index.es.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.es.js","require":"./dist/index.cjs.js","types":"./dist/index.d.ts"}},"license":"MIT","publishConfig":{"access":"public"},"dependencies":{},"gitHead":"1715846b4800a29e490550d12e2bc12daac1361e","description":"### `Emitter` ```js import { Emitter } from '@deot/helper-emitter';","_id":"@deot/helper-emitter@1.0.1","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-WmhBo4F+9+tdx1jsappBGIv1ZJfr+XE0tuGeVbfS68GQKw9IXpvPlQbC7UfXIoHKpZbDoUT89clPDr1QZBLxGw==","shasum":"195162c6bee3558bee65dcf59bd30b43951b7161","tarball":"https://registry.npmjs.org/@deot/helper-emitter/-/helper-emitter-1.0.1.tgz","fileCount":7,"unpackedSize":11973,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDOsX92WO87mc39laRFTdODCngH2bCSTsb2KrTHEFS/wgIhAJAw+ydpswmkNusoXkOoBbo15IHD2CFOVGk1HFSNmVYp"}]},"_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"directories":{},"maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/helper-emitter_1.0.1_1689263238369_0.2826578547135299"},"_hasShrinkwrap":false},"1.1.0":{"name":"@deot/helper-emitter","version":"1.1.0","type":"module","main":"dist/index.es.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.es.js","require":"./dist/index.cjs.js","types":"./dist/index.d.ts"}},"license":"MIT","publishConfig":{"access":"public"},"dependencies":{},"_id":"@deot/helper-emitter@1.1.0","gitHead":"aa9e40ce9edfdf36ab99d6a77571d691acaf03f9","description":"### `Emitter` ```js import { Emitter } from '@deot/helper-emitter';","_nodeVersion":"20.5.1","_npmVersion":"9.8.0","dist":{"integrity":"sha512-/cFV3oIFyVRG4o+R2DCp0w+nW/94LGldSL3WXVZOhy5VPB3On7SF45oWNPbGq7tkppSe9fLI7B1+fKicZZYvvg==","shasum":"d663781d342fa803eee31f594bd8c2ea9ddb98f5","tarball":"https://registry.npmjs.org/@deot/helper-emitter/-/helper-emitter-1.1.0.tgz","fileCount":7,"unpackedSize":11960,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAfeIt3uecolO381PIAJNHflHSQhkaXdWrKzXIMjKJyeAiBewrwpfYHW/AXe8xETLqPGYd4/bq6Lh3W63B5zwrZVLw=="}]},"_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"directories":{},"maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/helper-emitter_1.1.0_1692857121301_0.8206872796392874"},"_hasShrinkwrap":false},"1.1.1":{"name":"@deot/helper-emitter","version":"1.1.1","type":"module","main":"dist/index.es.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.es.js","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"license":"MIT","publishConfig":{"access":"public"},"dependencies":{},"_id":"@deot/helper-emitter@1.1.1","gitHead":"cb85757afa34ff538c72073a6799f866fc40509c","description":"### `Emitter` ```js import { Emitter } from '@deot/helper-emitter';","_nodeVersion":"20.5.1","_npmVersion":"9.8.0","dist":{"integrity":"sha512-WI505iw1ry898V7JXVbxmWSxCXcYkVkMDmyiel67nw0ke9ZVFV1vBIdcS76ypPczWozcy3y47l1I9w7YP+WQIw==","shasum":"6c48e34288df763fb0e5083a94cd4e87f3883355","tarball":"https://registry.npmjs.org/@deot/helper-emitter/-/helper-emitter-1.1.1.tgz","fileCount":7,"unpackedSize":11957,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCsheGRUfbFpsTVttvQ0KHSKbAG1PKl1p2WAw06F3QoSwIgb4cFNO4/J9huJyokcc2h1KGnAnHp0y2gp99OwVSZpm0="}]},"_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"directories":{},"maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/helper-emitter_1.1.1_1692930925139_0.7632469701011266"},"_hasShrinkwrap":false},"1.1.3":{"name":"@deot/helper-emitter","version":"1.1.3","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"license":"MIT","publishConfig":{"access":"public"},"dependencies":{},"_id":"@deot/helper-emitter@1.1.3","gitHead":"980a65f7e7e40322974c1719f22e4011687b78c1","description":"### `Emitter` ```js import { Emitter } from '@deot/helper-emitter';","_nodeVersion":"21.2.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-zF0B/aw0vDS8JlWjhZhjngDATKfLBIxmbx9IlZJ+oOUCuJRn75SMaRqOONDIvqrkExBGiMfF6GGvFHlzT6GWRw==","shasum":"4c08fe1440fd65b99125c4a76c0df50cd33d75dc","tarball":"https://registry.npmjs.org/@deot/helper-emitter/-/helper-emitter-1.1.3.tgz","fileCount":7,"unpackedSize":11951,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDY3ZrIHBaXaM/zadYQaS5JCsHTfBp0P0iu38iNozCIigIhAOd4xLDYkHzanPP2qlLYHoupmcPUUrxhtWS+9INXt32a"}]},"_npmUser":{"name":"deot","email":"zrd0921@qq.com"},"directories":{},"maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/helper-emitter_1.1.3_1700642925533_0.5151163855861836"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-13T15:47:18.177Z","1.0.1":"2023-07-13T15:47:18.554Z","modified":"2023-11-22T08:48:45.995Z","1.1.0":"2023-08-24T06:05:21.438Z","1.1.1":"2023-08-25T02:35:25.296Z","1.1.3":"2023-11-22T08:48:45.846Z"},"maintainers":[{"name":"deot","email":"zrd0921@qq.com"}],"description":"### `Emitter` ```js import { Emitter } from '@deot/helper-emitter';","license":"MIT","readme":"# @deot/helper-emitter\n\n### `Emitter`\n```js\nimport { Emitter } from '@deot/helper-emitter';\n\n// or\nimport { Emitter } from '@deot/helper';\n\n```\n\n### 示例\n\n```js\nlet source = new Emitter({ a: 2 });\n\n// 订阅事件 ，不使用'() => {}', 使用'function() {}'可以拿到当前对象，进行链式操作\nsource.on('[event-name]', ({ name }) => {\n\tconsole.log(name, this);\n});\n\n// 订阅listener\nsource.on(({ name }) => {\n\tconsole.log(name, this);\n});\n\n// 发布事件，第一个值事件，第二个值参数\nsource.emit('[event-name]', { name: 'wya-ps' }); \n\n// 取消事件订阅\nsource.off('[event-name]');\n\n// 取消订阅listener\nsource.off();\n```\n\n## API\n\n---\n\n### `on` \n\n`source.on(eventName: string, callback: Function)`\n\n订阅事件\n\n+ **eventName**: 绑定的事件名。\n+ **callback**: 回调。\n\n**示例**\n```js\nsource.on('[event-name]', ({ name }) => {\n\tconsole.log(name, this);\n});\n```\n\n---\n\n### `once` \n\n`source.once(eventName: string, callback: Function)`\n\n一次订阅\n\n+ **eventName**: 绑定的事件名。\n+ **callback**: 回调。\n\n**示例**\n```js\nsource.once('[event-name]', ({ name }) => {\n\tconsole.log(name, this);\n});\n```\n\n---\n\n### `off` \n\n`source.off(eventName: string, callback: Function)`\n\n取消订阅\n\n+ **eventName**: 绑定的事件名。\n+ **callback**: 回调。\n\n**示例**\n```js\n// 取消事件订阅, 指定回调\nsource.off('[event-name]', fn);\n\n// 取消事件订阅\nsource.off('[event-name]');\n\n// 取消订阅listener\nsource.off();\n```\n\n---\n\n### `emit` \n\n`source.emit(eventName: string, params: Object)`\n\n发布事件\n\n+ **eventName**: 触发事件名。\n+ **params**: 给回调的参数。\n\n**示例**\n```js\n// 发布事件，第一个值事件，第二个值参数\nsource.emit('[event-name]', { name: 'wya-ps' }); \n```\n\n---\n\n### `listener` \n\n`source.on(callback: Function)`\n\n监听\n\n+ **params**: 监听器的回调。\n\n**示例**\n```js\n// 订阅listener\nsource.on(({ name }) => {\n\tconsole.log(name, this);\n});\n\n// 取消订阅listener\nsource.off();\n```","readmeFilename":"README.md"}