{ "info": { "author": "Miraculous Owonubi", "author_email": "omiraculous@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# node_events.py\n\n> A minor rewrite of the NodeJS EventEmitter in Python\n\n[![PyPI Version][pypi-image]][pypi-url]\n![License][license-image]\n![Python Version][version-image]\n\n## Installing\n\nVia [PyPI][pypi-url]:\n\n``` bash\npip install node_events\n```\n\n## Usage\n\n``` python\nfrom node_events import EventEmitter\n\nmyEmitter = EventEmitter()\n\n\ndef fn():\n print(\"An event occurred\")\n\n\nmyEmitter.on('event', fn)\nmyEmitter.emit('event')\n\n# Prints\n# An event occurred\n\n```\n\n## API\n\n### Class: `EventEmitter`\n\nThe `EventEmitter` class is defined and exposed publicly by the module:\n``` python\nfrom node_events import EventEmitter\n```\n\n#### EventEmitter.`addListener`(eventName, listener)\n\n* `eventName`: <string>\n* `listener`: <function>\n* Returns: <[EventEmitter](#eventemitter)>\n\nAlias for [`self.on(eventName, listener)`](#eventemitter_on)\n\nEmits the `'addlistener:{eventName}'` event when called.\n\n#### EventEmitter.`on`(eventName, listener)\n\n* `eventName`: <string> The name of the event.\n* `listener`: <function> The callback function.\n* Returns: <[EventEmitter](#eventemitter)>\n\nAppends the `listener` to the listeners array for the event named `eventName`. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.\n\nEmits the `'addlistener:{eventName}'` event when called.\n\nBy default, event listeners are invoked in the order they are added. The [`emitter.prependListener()`](#eventemitter_prependlistener) method can be used as an alternative to add the event listener to the beginning of the listeners array.\n\nReturns a reference to the `EventEmitter`, so that calls can be chained.\n\n``` python\nemitter = EventEmitter()\n\ndef appendListener():\n print('a')\n\ndef prependListener():\n print('b')\n\nemitter.on('test', appendListener)\nemitter.prependListener('test', appendListener)\n\nemitter.emit('test')\n\n# Prints\n# b\n# a\n```\n\n#### EventEmitter.`once`(eventName, listener)\n\n* `eventName`: <string> The name of the event.\n* `listener`: <function> The callback function.\n* Returns: <[EventEmitter](#eventemitter)>\n\nAdds a **one-time** `listener` function for the event named `eventName`. The next time `eventName` is triggered, this listener is removed and then invoked.\n\nEmits the `'addlistener:{eventName}'` event when called.\n\nBy default, event listeners are invoked in the order they are added. The [`emitter.prependOnceListener()`](#eventemitter_prependoncelistener) method can be used as an alternative to add the event listener to the beginning of the listeners array.\n\nReturns a reference to the `EventEmitter`, so that calls can be chained.\n\n``` python\nemitter = EventEmitter()\n\ndef appendListener():\n print('a')\n\ndef prependListener():\n print('b')\n\nemitter.once('test', appendListener)\nemitter.prependOnceListener('test', appendListener)\n\nemitter.emit('test')\n\n# Prints\n# b\n# a\n```\n\n#### EventEmitter.`prependListener`(eventName, listener)\n\n* `eventName`: <string> The name of the event.\n* `listener`: <function> The callback function.\n* Returns: <[EventEmitter](#eventemitter)>\n\nAdds the `listener` function to the beginning of the listeners array for the event named `eventName`. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.\n\nEmits the `'addlistener:{eventName}'` event when called.\n\n``` python\nemitter = EventEmitter()\n\ndef newConnection():\n print('someone connected!')\n\nemitter.prependListener('connection', newConnection)\nemitter.emit('connection')\n```\n\nReturns a reference to the `EventEmitter`, so that calls can be chained.\n\n#### EventEmitter.`prependOnceListener`(eventName, listener)\n\n* `eventName`: <string> The name of the event.\n* `listener`: <function> The callback function.\n* Returns: <[EventEmitter](#eventemitter)>\n\nAdds a **one-time** `listener` function for the event named `eventName` to the beginning of the listeners array. The next time `eventName` is triggered, this listener is removed, and then invoked.\n\nEmits the `'addlistener:{eventName}'` event when called.\n\n``` python\nemitter = EventEmitter()\n\ndef newConnection():\n print('someone connected!')\n\nemitter.prependOnceListener('connection', newConnection)\nemitter.emit('connection')\n```\n\nReturns a reference to the `EventEmitter`, so that calls can be chained.\n\n#### EventEmitter.`removeAllListeners`([eventName])\n\n* `eventName`: <string> The name of the event.\n* Returns: <[EventEmitter](#eventemitter)>\n\nRemoves all listeners, or those of the specified `eventName`.\n\nEmits the `'rmlistener:{eventName}'` event when called.\n\nReturns a reference to the EventEmitter, so that calls can be chained.\n\n#### EventEmitter.`removeListener`(eventName, listener)\n\n* `eventName`: <string>\n* `listener`: <function>\n* Returns: <[EventEmitter](#eventemitter)>\n\nRemoves the specified `listener` from the listener array for the event named `eventName`.\n\nEmits the `'rmlistener:{eventName}'` event when called.\n\n#### EventEmitter.`hasEvent`(eventName, raiseException)\n\n* `eventName`: <string>\n* `raiseException`: <boolean> (**Default**: `False`)\n* Returns: <[EventEmitter](#eventemitter)>\n\nCheck if the event emitter has within itself an event named `eventName`, return a boolean for the operation.\nif `raiseException` is True, raise an exception if the result of the check evaluates to `False`.\n\n#### EventEmitter.`hasListeners`(eventName)\n\n* `eventName`: <string>\n* `raiseException`: <boolean>\n* Returns: <[EventEmitter](#eventemitter)>\n\nSafely check that the core [EventListenerStack](#eventlistenerstack) has at least one listener.\nImplements the [`EventListenerStack::hasListeners()`](#eventlistenerstack_haslisteners) inherently.\n\n### Class: `EventListener`(listener)\n\n* `listener`: <function>\n\nThis class wraps the `listener` function with useful, sandboxed manipulative features\n\nThe `EventListener` class is defined and exposed publicly by the module:\n``` python\nfrom node_events import EventListener\n\ndef fn():\n print(\"test_fn\")\n\nEventListener(fn).respond()\n\n# Prints\n# test_fn\n```\n\n#### EventListener.`listenerCount`(getter)\n\nNumber of times the function has been called\n\n#### EventListener.`respond`(*data)\n\n* `*data`: <any>\n\nSend the `data` arguments to the encapsulated function in evaluation\n\n#### EventListener.`verify`(fn)\n\n* `fn`: <function>\n* Returns: <boolean>\n\nCheck if `fn` matches with the encapsulated function\nUseful in finding the instance amongst others by matching its core\n\n### Class: `EventListenerStack`(eventName)\n\n* `eventName`: <string>\n\nStacking layer of listeners for an event defined named `eventName`\nServes as an interfacing remote for series of grouped listeners\n\nThe `EventListenerStack` class is defined and exposed publicly by the module:\n``` python\nfrom node_events import EventListenerStack\n\ndef test_fn():\n print(\"hi from test_fn\")\n\nstack = EventListenerStack(\"event_name\")\nstack.attachListener(test_fn, 0)\nstack.respond()\n\n# Prints\n# hi from test_fn\n```\n\n#### EventListenerStack.`listeners`(getter)\n\nReturn a copy of the private listeners array.\n\n#### EventListenerStack.`listenerCount`(getter)\n\nReturn the number of listeners exist and are actively waiting for event firings\n\n#### EventListenerStack.`respond`(*data)\n\n* `*data`: <any>\n* Returns: <boolean>\n\nSend the `data` arguments to all the listeners within the stack in the order of which they appear\nReturns True if the stack has any active listeners who read the data else False\n\n#### EventListenerStack.`verifyHasListener`(fn)\n\n* `fn`: <function>\n\nCheck if the stack has the listener `fn`\n\n#### EventListenerStack.`attachListener`(fn, index)\n\n* `fn`: <function>\n* `index`: <number>\n\nAttach the `fn` listener to the event stack.\nThe `index` parameter determines the index at which to place the function in the stack array\nNote, function calls are based on orderly calls from the stack array\n\n#### EventListenerStack.`detachListener`(fn)\n\n* `fn`: <function>\n* Returns: <boolean>\n\nDetach the `fn` listener from the stack if it exists returning True otherwise return False\n\n#### EventListenerStack.`detachAllListeners`()\n\nDetach all the listeners within the stack\n\n#### EventListenerStack.`hasListeners`()\n\nCheck if the stack has any listeners within\n\n#### EventListenerStack.`extractInstanceOf`(fn)\n\n* `fn`: <function>\n\nExtract the [`EventListener`](#eventlistener) instance encapsulating the `fn` listener if it exists otherwise return `None`\n\n## Development\n\n### Building\n\nFeel free to clone, use in adherance to the [license](#license) and perhaps send pull requests\n\n``` bash\ngit clone https://github.com/miraclx/node_events.py.git\ncd node_events.py\n# hack on code\npip3 install . --user\n```\n\n## License\n\n[Apache 2.0][license] \u00a9 **Miraculous Owonubi** ([@miraclx][author-url]) <omiraculous@gmail.com>\n\n[license]: LICENSE 'Apache 2.0 License'\n[author-url]: https://github.com/miraclx\n\n[pypi-url]: https://pypi.org/project/node-events\n[pypi-image]: https://img.shields.io/pypi/v/node-events.svg?color=red&label=node-events&style=popout-square\n[license-image]: https://img.shields.io/pypi/l/node-events.svg?color=green&label=License&style=popout-square\n[version-image]: https://img.shields.io/pypi/pyversions/node-events.svg?color=blue&label=PythonVersion&style=popout-square\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/miraclx/node_events.py", "keywords": "", "license": "Apache-2.0", "maintainer": "", "maintainer_email": "", "name": "node-events", "package_url": "https://pypi.org/project/node-events/", "platform": "", "project_url": "https://pypi.org/project/node-events/", "project_urls": { "Homepage": "https://github.com/miraclx/node_events.py" }, "release_url": "https://pypi.org/project/node-events/0.6.9/", "requires_dist": null, "requires_python": "", "summary": "A minor rewrite of the NodeJS EventEmitter in Python", "version": "0.6.9" }, "last_serial": 5488958, "releases": { "0.5.0": [ { "comment_text": "", "digests": { "md5": "fbf3f60c8e552a0f0acc5936bb2fa968", "sha256": "39f17f9e4af1a010c4660485ff1ffc55206bd667a3b9fc2b862cd53c9e3e0521" }, "downloads": -1, "filename": "node_events-0.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fbf3f60c8e552a0f0acc5936bb2fa968", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6709, "upload_time": "2019-05-22T00:08:18", "url": "https://files.pythonhosted.org/packages/f2/f5/8a2d22ee57ed7c6ac02cce96204e3b9bb49a83ac573cb41ab191dd5f0ebf/node_events-0.5.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fdf6bb67e4e1e895bd5904ce47860b2b", "sha256": "5578cfae63457dd358488d7f803d0f280fd0eaf6a7580c290a6bebfe1414c3b5" }, "downloads": -1, "filename": "node_events-0.5.0.tar.gz", "has_sig": false, "md5_digest": "fdf6bb67e4e1e895bd5904ce47860b2b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2098, "upload_time": "2019-05-22T00:08:21", "url": "https://files.pythonhosted.org/packages/15/24/503be326e2d720de17e642fe11b0c71333ed9c84dc850eaba0e9e94b9109/node_events-0.5.0.tar.gz" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "ddc3426bc6f187a96d458ef3b7382588", "sha256": "ee5ee02dbe98c584bff513249e29fb2d26d2254be13c5aca413ec24192fc3cda" }, "downloads": -1, "filename": "node_events-0.5.2-py3-none-any.whl", "has_sig": false, "md5_digest": "ddc3426bc6f187a96d458ef3b7382588", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7854, "upload_time": "2019-05-22T01:59:02", "url": "https://files.pythonhosted.org/packages/a0/e6/47d1ea703fd237918d6cefdc4fa8475f6ba670fb83f22d4f7c169674ca3d/node_events-0.5.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d2cecd3a80f1627f8d361c72d14f7b61", "sha256": "7c99a04b408496990260a6f70cf83680016e780c174488bb0e1ab10e2cdef522" }, "downloads": -1, "filename": "node_events-0.5.2.tar.gz", "has_sig": false, "md5_digest": "d2cecd3a80f1627f8d361c72d14f7b61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3690, "upload_time": "2019-05-22T01:59:05", "url": "https://files.pythonhosted.org/packages/e0/3f/e58e673953c782232b07e9eb23857e4f624edfd3f3b2f77c631b70904ab1/node_events-0.5.2.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "d1f9169458cdea17a371ed6a45ae2c41", "sha256": "f61716a1f135fef114792d4fcea5b680f58b04383ccde03056a55f06573775d6" }, "downloads": -1, "filename": "node_events-0.6.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d1f9169458cdea17a371ed6a45ae2c41", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9087, "upload_time": "2019-05-22T03:27:59", "url": "https://files.pythonhosted.org/packages/b0/6b/a9a1c84e96c346bfe523d9589318922bd775a66f641eb6e4cb6c3c3b44bf/node_events-0.6.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d0e97646e6028deeae4a1acf732563b5", "sha256": "ddf22c0a463ef0dd282399fa762f508d35bfb714246e05eafd19054b62ae2763" }, "downloads": -1, "filename": "node_events-0.6.0.tar.gz", "has_sig": false, "md5_digest": "d0e97646e6028deeae4a1acf732563b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5291, "upload_time": "2019-05-22T03:28:03", "url": "https://files.pythonhosted.org/packages/e9/2f/9100b18b683f8d83170a87fe08807762616b6613cd48935b97334d2f401f/node_events-0.6.0.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "0ba41542d8b9cb41da2f6200354c2b48", "sha256": "081dd9ca640ca51ef708dcee6b8d0f0014ff95458627000669da9d26c1b12a76" }, "downloads": -1, "filename": "node_events-0.6.1-py3-none-any.whl", "has_sig": false, "md5_digest": "0ba41542d8b9cb41da2f6200354c2b48", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9063, "upload_time": "2019-05-22T03:39:33", "url": "https://files.pythonhosted.org/packages/26/94/73ae6d8d9ca66f1b2d1fa6e809c0e4ab2665d5bc8a910b5d2ac6abb17ebe/node_events-0.6.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "709534a5cd9ce9d02801a9c014ae910c", "sha256": "03303d2b897772321e69726a72d297ae65af6d88b2d145e08967bde4d5bee70f" }, "downloads": -1, "filename": "node_events-0.6.1.tar.gz", "has_sig": false, "md5_digest": "709534a5cd9ce9d02801a9c014ae910c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5262, "upload_time": "2019-05-22T03:39:35", "url": "https://files.pythonhosted.org/packages/c4/6e/1b3e523bf9e9727ba5c49a236d19d40f58a1029e6a982b37febba22848bb/node_events-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "36c6a999b3d48102e25d77d26735445a", "sha256": "1448a4b7e84d3fc9c3ea7f8e582e302e11da003a7c8ada7be13d055ea072279b" }, "downloads": -1, "filename": "node_events-0.6.2-py3-none-any.whl", "has_sig": false, "md5_digest": "36c6a999b3d48102e25d77d26735445a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9064, "upload_time": "2019-05-22T18:59:00", "url": "https://files.pythonhosted.org/packages/8a/f1/54c6694ca217d554e0d0835ddb40907883adc8a7adfadd9841f0dc91c795/node_events-0.6.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e9775e246d4cc8d0dc97b76b5e96c4c1", "sha256": "a212f1b89f636b139d84d3ebf9a4b3e32f1c5812eee9330c005578e87b4125b1" }, "downloads": -1, "filename": "node_events-0.6.2.tar.gz", "has_sig": false, "md5_digest": "e9775e246d4cc8d0dc97b76b5e96c4c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5263, "upload_time": "2019-05-22T18:59:05", "url": "https://files.pythonhosted.org/packages/97/93/20ba87ba7dba9325116ff68c1e0d0d64d4c2dd22f6ed5974b4c5a1c460da/node_events-0.6.2.tar.gz" } ], "0.6.5": [ { "comment_text": "", "digests": { "md5": "6b2fe685d7640cfb2610426089eb9490", "sha256": "1bb8dc0b50248a39805c147237c92339624af26cd057194266e2af9877315d01" }, "downloads": -1, "filename": "node_events-0.6.5-py3-none-any.whl", "has_sig": false, "md5_digest": "6b2fe685d7640cfb2610426089eb9490", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9065, "upload_time": "2019-07-04T22:43:09", "url": "https://files.pythonhosted.org/packages/37/f2/22de19225abd1fcad9d6d08bf9cd9f186c505858b2f4d21efe21f86deb91/node_events-0.6.5-py3-none-any.whl" } ], "0.6.8": [ { "comment_text": "", "digests": { "md5": "d91891a9e0ba87bfd8af41150c39e949", "sha256": "2ae10526bb8846088939423ab72021b6dbcdc0c9f3423a0b57cc0967b4049f0c" }, "downloads": -1, "filename": "node_events-0.6.8-py3-none-any.whl", "has_sig": false, "md5_digest": "d91891a9e0ba87bfd8af41150c39e949", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9066, "upload_time": "2019-07-04T22:43:12", "url": "https://files.pythonhosted.org/packages/5c/e7/c6502f5000af247069557bf6c72009da54516a68d62ebed48aed08740a31/node_events-0.6.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6d7895465f50cad5afce549fdc0cd409", "sha256": "c2eb6c603c3190f16868d26c54f867a7cc582bf3ea2d3ac0893f11bc540c0417" }, "downloads": -1, "filename": "node_events-0.6.8.tar.gz", "has_sig": false, "md5_digest": "6d7895465f50cad5afce549fdc0cd409", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5278, "upload_time": "2019-07-04T22:43:19", "url": "https://files.pythonhosted.org/packages/85/16/5d5bec002bf37681d92103741211920ece6524659cf8f6e517f1e78929f3/node_events-0.6.8.tar.gz" } ], "0.6.9": [ { "comment_text": "", "digests": { "md5": "47b0a5928c4d91285f40fe067aafa9d4", "sha256": "160c6f4f2f3535eaa851c4a072aa853b65d12fd703474c182579c9c2b3e03665" }, "downloads": -1, "filename": "node_events-0.6.9-py3-none-any.whl", "has_sig": false, "md5_digest": "47b0a5928c4d91285f40fe067aafa9d4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9064, "upload_time": "2019-07-04T22:43:17", "url": "https://files.pythonhosted.org/packages/42/dd/9fff410c34aff104f569ac3d0f1d5fcf1f203bdfd3b908b928cdf2f8bfbe/node_events-0.6.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "38001ce23087abe1b689dcc0b2e2f1a2", "sha256": "933d7da7ddebe450cf53297c168bb5cdc1ce706980957978e48aa4ade1d3203b" }, "downloads": -1, "filename": "node_events-0.6.9.tar.gz", "has_sig": false, "md5_digest": "38001ce23087abe1b689dcc0b2e2f1a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5279, "upload_time": "2019-07-04T22:43:20", "url": "https://files.pythonhosted.org/packages/a8/11/9b2735dab65d42dfed509de6ab25643174456b89c89adf14ba57480f8632/node_events-0.6.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "47b0a5928c4d91285f40fe067aafa9d4", "sha256": "160c6f4f2f3535eaa851c4a072aa853b65d12fd703474c182579c9c2b3e03665" }, "downloads": -1, "filename": "node_events-0.6.9-py3-none-any.whl", "has_sig": false, "md5_digest": "47b0a5928c4d91285f40fe067aafa9d4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9064, "upload_time": "2019-07-04T22:43:17", "url": "https://files.pythonhosted.org/packages/42/dd/9fff410c34aff104f569ac3d0f1d5fcf1f203bdfd3b908b928cdf2f8bfbe/node_events-0.6.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "38001ce23087abe1b689dcc0b2e2f1a2", "sha256": "933d7da7ddebe450cf53297c168bb5cdc1ce706980957978e48aa4ade1d3203b" }, "downloads": -1, "filename": "node_events-0.6.9.tar.gz", "has_sig": false, "md5_digest": "38001ce23087abe1b689dcc0b2e2f1a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5279, "upload_time": "2019-07-04T22:43:20", "url": "https://files.pythonhosted.org/packages/a8/11/9b2735dab65d42dfed509de6ab25643174456b89c89adf14ba57480f8632/node_events-0.6.9.tar.gz" } ] }