Metadata-Version: 2.1
Name: PyJSCaller
Version: 0.1.1
Summary: Run JavaScript code from Python
Home-page: https://github.com/ZSAIm/PyJSCaller
Author: ZSAIm
Author-email: zzsaim@163.com
License: MIT License
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: JavaScript

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


.. code:: javascript

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


Usage
---------------

.. code:: python

	>>> import jscaller
	>>> jscaller.eval("'Hello World!'.toUpperCase()")
	'HELLO WORLD!'
	>>> with jscaller.Session('example.js', timeout=3) as sess:
	...     add = sess.get('add')
	...     retval = add(add(1, 2), 2)
	...     sess.call(retval)
	>>> retval.getValue()
	5


Supported JSEngine 
====================

* `NodeJS <https://nodejs.org/>`_ - defalut
* `PhantomJS <https://phantomjs.org/>`_


Installation
===============

    $ pip install PyJSCaller

More Examples
===============

Another short example

.. code:: python

	>>> from jscaller.collect import new, String
	>>> with jscaller.Session() as sess:
	...     string = new(String("Hello JavaScript!"))
	...     string.replace('JavaScript', 'Python')
	...     sess.call(string)
	>>> string.getValue()
	"Hello Python!"


Using ``jscaller.make()`` to equip other JSEngine: 

.. code:: python

	>>> from jscaller.engine import NodeJS, PhantomJS
	>>> PhantomJS.environ(shell=True, timeout=5)
	>>> jscaller.make(PhantomJS)
	>>> jscaller.eval('1+1*2/4')
	1.5


You can use ``PhantomJS.test()`` to check if engine worked correctly. 

.. code:: python

	>>> PhantomJS.test()    # return the version number of PhantomJS
	2.1.1 



License
===============
MIT license

Changelog
===============

0.1.1
---------------

* Rebuilt all.
* Linux was supported.
* Python 3.7.x was supported.
* Python 2.7.x was supported. 

0.0.1
---------------

* Uploaded code.


