Skip to main content

PyJSCaller

Run JavaScript code from Python.

PyJSCaller is a agent between Python and JavaScript making JavaScript involved in a more Python-like language.

a short example:


example.js

function add(a, b){
        return a + b;
}

Supported JSEngine

Installation

$ pip install PyJSCaller

Example

Usage1

>>> import jscaller
>>> jscaller.eval("'Hello World!'.toUpperCase()")
'HELLO WORLD!'

Usage2

>>> ctx = jscaller.compile('example.js', timeout=3)
>>> ctx.call('add', 1, 1)
2

Usage3

>>> with jscaller.session('example.js') as sess:
...     add, math = sess.get('add', 'Math')
...     res1 = add(2, 3)
...     res2 = math.PI + math.E
...     sess.call(res1, res2)
...
>>> res1.get_value()
5
>>> res2.get_value()
5.859874482048838

Change JSEngine

>>> from jscaller.engine import PhantomJS
>>> PhantomJS.test()
2.1.1
>>> PhantomJS.config(timeout=10)
>>> jscaller.make(PhantomJS)
>>> jscaller.eval('1+1')
2

License

MIT license

Metadata

Release files for PyJSCaller 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyJSCaller 0.2.1
File Size Uploaded Provenance Actions
PyJSCaller-0.2.1.tar.gz 10.7 kB Without provenance Details for PyJSCaller-0.2.1.tar.gz

Release files / PyJSCaller-0.2.1.tar.gz

Download URL PyJSCaller-0.2.1.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
26f4b059ee93f72fbab0d26bb1261723fe599040ef300e43cd9ee2379b8b17da
BLAKE2b-256 checksum
How to use checksums
7588607014d08cbdc74f3c878a8c21d2eef7f5fbe782875d689e41f66922daf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.0 CPython/3.7.7

Security for PyJSCaller 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page