javascriptasync


Namejavascriptasync JSON
Version 0.2.2.7 PyPI version JSON
download
home_pageNone
Summaryfork of JSPyBridge overhauled to allow for asyncio compatibility and more control.
upload_time2024-03-20 14:39:59
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseThe MIT License (MIT) Copyright (c) 2023 CrosswaveOmega Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords node javascript bridge development fork
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # JSPyBridge_async - javascript asyncio fork
[![PyPI](https://img.shields.io/pypi/v/javascriptasync)](https://pypi.org/project/javascriptasync/)
[![Documentation Status](https://readthedocs.org/projects/asyncjavascriptbridge/badge/?version=latest)](https://asyncjavascriptbridge.readthedocs.io/?badge=latest)
[![Build Status](https://github.com/CrosswaveOmega/JSPyBridge_Async/workflows/Node.js%20CI/badge.svg)](https://github.com/extremeheat/JSPyBridge/actions/workflows/)



Interoperate Node.js from Python, with built in asyncio compatibility. 

This is a fork of [JSPyBridge](https://github.com/extremeheat/JSPyBridge) by extremeheat, created to properly integrate `asyncio` events and coroutines into the python side of the bridge.

As the purpose of this fork was only to alter the `javascript` package, it's specifically for running Node.js from Python.  No changes are made to `pythonia` or are planned to be made to `pythonia`.
### current stable installation
```
 pip install -U javascriptasync
```
### current latest installation
```
 pip install -U git+https://github.com/CrosswaveOmega/JSPyBridge_Async.git
```


Requires Node.js 14 and Python 3.8 or newer.

## Key Features
* use node.js objects in the same way as python modules.
* Ability to call async and sync functions and get object properties with a native feel
* Built-in garbage collection
* Bidirectional callbacks with arbitrary arguments
* Iteration and exception handling support
* Object inspection allows you to easily `console.log` or `print()` any foreign objects

* (Bridge to call JS from Python) Specialized object oriented support for event-emitter functions.
* retrieve blob objects from the Javascript side of the bridge.
* enhanced support for concurrent operations.

### New Javascript from Python usage:
```py
import asyncio
from javascriptasync import init_js, require_a, get_globalThis
init_js()
async def main():
  chalk, fs = await require_a("chalk")
  globalThis=get_globalThis()
  datestr=await (await globalThis.Date(coroutine=True)).toLocaleString(coroutine=True)
  print("Hello", chalk.red("world!"), "it's", datestr)
  fs.writeFileSync("HelloWorld.txt", "hi!")

asyncio.run(main)
```
## TO DO:
 * better documentation and examples
 * bug fixing/optimization
 * Code cleanup.


## KEY CHANGES:
* `javascript` is now `javascriptasync`
* `config.py` has been encapsulated into the `JSConfig` class, all objects that need to access variables within `JSConfig` have been passed an object reference to a single unique `JSConfig` instance.
 * `__init__.py` utilizes a singleton to ensure that only one instance of an JSConfig class is created at any one time.  You need to call `init()` to start up the bridge!
 * The `JSContext` object can be utilized to make use of the library's operations in a more object oriented manner.
* debug output now uses the logging module.
* `connection.py` has been encapsulated into the `ConnectionClass`, accessable through the `events.EventLoop` class, as `events.EventLoop` is the only place the connection was ever utilized.
* It's possible to set a custom timeout value when using eval_js.
* async variants of `require` and `eval_js` are included within __init__.py, as `require_a` and `eval_js_a` respectively.
* this package is now built using a `pyproject.toml` file instead of a `setup.py` script.
* `test_general.py` now works with pytest.
* `console`, `globalThis`, and `RegExp` have to be retrieved with the `get_console()`, `get_globalThis()`, and `get_RegExp()` functions.
* `start`, `stop`, and `abort` has to be retrieved with through the `ThreadUtils` static class.
* any call or init operation can be made into a coroutine by passing in the `coroutine=True` keyword.
* Separate set of wrappers for asyncio tasks through `AsyncTaskUtils` 
* Event Emitters can utilize Coroutine handlers.


### Examples
 see https://github.com/CrosswaveOmega/JSPyBridge_Async/tree/master/examples


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "javascriptasync",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "node, javascript, bridge, development, fork",
    "author": null,
    "author_email": "Crosswave Omega <xtream2pro@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/0c/56/2bacde479c62966a1cf9c2f9ee35d49e52603a2cc15d1f181e99c920ae0a/javascriptasync-0.2.2.7.tar.gz",
    "platform": null,
    "description": "# JSPyBridge_async - javascript asyncio fork\n[![PyPI](https://img.shields.io/pypi/v/javascriptasync)](https://pypi.org/project/javascriptasync/)\n[![Documentation Status](https://readthedocs.org/projects/asyncjavascriptbridge/badge/?version=latest)](https://asyncjavascriptbridge.readthedocs.io/?badge=latest)\n[![Build Status](https://github.com/CrosswaveOmega/JSPyBridge_Async/workflows/Node.js%20CI/badge.svg)](https://github.com/extremeheat/JSPyBridge/actions/workflows/)\n\n\n\nInteroperate Node.js from Python, with built in asyncio compatibility. \n\nThis is a fork of [JSPyBridge](https://github.com/extremeheat/JSPyBridge) by extremeheat, created to properly integrate `asyncio` events and coroutines into the python side of the bridge.\n\nAs the purpose of this fork was only to alter the `javascript` package, it's specifically for running Node.js from Python.  No changes are made to `pythonia` or are planned to be made to `pythonia`.\n### current stable installation\n```\n pip install -U javascriptasync\n```\n### current latest installation\n```\n pip install -U git+https://github.com/CrosswaveOmega/JSPyBridge_Async.git\n```\n\n\nRequires Node.js 14 and Python 3.8 or newer.\n\n## Key Features\n* use node.js objects in the same way as python modules.\n* Ability to call async and sync functions and get object properties with a native feel\n* Built-in garbage collection\n* Bidirectional callbacks with arbitrary arguments\n* Iteration and exception handling support\n* Object inspection allows you to easily `console.log` or `print()` any foreign objects\n\n* (Bridge to call JS from Python) Specialized object oriented support for event-emitter functions.\n* retrieve blob objects from the Javascript side of the bridge.\n* enhanced support for concurrent operations.\n\n### New Javascript from Python usage:\n```py\nimport asyncio\nfrom javascriptasync import init_js, require_a, get_globalThis\ninit_js()\nasync def main():\n  chalk, fs = await require_a(\"chalk\")\n  globalThis=get_globalThis()\n  datestr=await (await globalThis.Date(coroutine=True)).toLocaleString(coroutine=True)\n  print(\"Hello\", chalk.red(\"world!\"), \"it's\", datestr)\n  fs.writeFileSync(\"HelloWorld.txt\", \"hi!\")\n\nasyncio.run(main)\n```\n## TO DO:\n * better documentation and examples\n * bug fixing/optimization\n * Code cleanup.\n\n\n## KEY CHANGES:\n* `javascript` is now `javascriptasync`\n* `config.py` has been encapsulated into the `JSConfig` class, all objects that need to access variables within `JSConfig` have been passed an object reference to a single unique `JSConfig` instance.\n * `__init__.py` utilizes a singleton to ensure that only one instance of an JSConfig class is created at any one time.  You need to call `init()` to start up the bridge!\n * The `JSContext` object can be utilized to make use of the library's operations in a more object oriented manner.\n* debug output now uses the logging module.\n* `connection.py` has been encapsulated into the `ConnectionClass`, accessable through the `events.EventLoop` class, as `events.EventLoop` is the only place the connection was ever utilized.\n* It's possible to set a custom timeout value when using eval_js.\n* async variants of `require` and `eval_js` are included within __init__.py, as `require_a` and `eval_js_a` respectively.\n* this package is now built using a `pyproject.toml` file instead of a `setup.py` script.\n* `test_general.py` now works with pytest.\n* `console`, `globalThis`, and `RegExp` have to be retrieved with the `get_console()`, `get_globalThis()`, and `get_RegExp()` functions.\n* `start`, `stop`, and `abort` has to be retrieved with through the `ThreadUtils` static class.\n* any call or init operation can be made into a coroutine by passing in the `coroutine=True` keyword.\n* Separate set of wrappers for asyncio tasks through `AsyncTaskUtils` \n* Event Emitters can utilize Coroutine handlers.\n\n\n### Examples\n see https://github.com/CrosswaveOmega/JSPyBridge_Async/tree/master/examples\n\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2023 CrosswaveOmega  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "fork of JSPyBridge overhauled to allow for asyncio compatibility and more control.",
    "version": "0.2.2.7",
    "project_urls": {
        "Homepage": "https://github.com/CrosswaveOmega/JSPyBridge_Async"
    },
    "split_keywords": [
        "node",
        " javascript",
        " bridge",
        " development",
        " fork"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c4df25f85f8fe4950307d4e0f06f9825a8388f76163f84f99fc9e05ad40fb9c0",
                "md5": "258697499eae76e1632739cacc38ff84",
                "sha256": "254159ab71cc022068f1bd810d2199c813ded2f3a2882daaaa723f1996f4bf6e"
            },
            "downloads": -1,
            "filename": "javascriptasync-0.2.2.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "258697499eae76e1632739cacc38ff84",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 79085,
            "upload_time": "2024-03-20T14:39:57",
            "upload_time_iso_8601": "2024-03-20T14:39:57.594119Z",
            "url": "https://files.pythonhosted.org/packages/c4/df/25f85f8fe4950307d4e0f06f9825a8388f76163f84f99fc9e05ad40fb9c0/javascriptasync-0.2.2.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0c562bacde479c62966a1cf9c2f9ee35d49e52603a2cc15d1f181e99c920ae0a",
                "md5": "461a4fb944b9666603c6b6a77dcb3e17",
                "sha256": "1dedeecd76431ec302b1bf7d50517c6c6cfa194dab76160dffbf0564183514a0"
            },
            "downloads": -1,
            "filename": "javascriptasync-0.2.2.7.tar.gz",
            "has_sig": false,
            "md5_digest": "461a4fb944b9666603c6b6a77dcb3e17",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 71294,
            "upload_time": "2024-03-20T14:39:59",
            "upload_time_iso_8601": "2024-03-20T14:39:59.411298Z",
            "url": "https://files.pythonhosted.org/packages/0c/56/2bacde479c62966a1cf9c2f9ee35d49e52603a2cc15d1f181e99c920ae0a/javascriptasync-0.2.2.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-20 14:39:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CrosswaveOmega",
    "github_project": "JSPyBridge_Async",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "javascriptasync"
}
        
Elapsed time: 0.19841s