Skip to main content

A port of Javascript API to python. Useful for interoperability, porting js code and more...

Project description

esx
JS API in python 3!

PyPI version Downloads Python version Build status Python package

Contains

esx : js API in python 3 😳

API

from esx import Math
print(Math.random())

from esx import Array
myArr=Array(1,2,3)
print(myArr.splice(1))

from esx import URL
url = URL('https://somesite.com/blog/article-one#some-hash')
print(url.protocol)
print(url.host)
print(url.pathname)
print(url.hash)

# you can use Global class to import all the js methods from the global namespace i.e
# from esx.esx import Global
# Global.decodeURIComponent(...
# Global.encodeComponent(...
# Global.setInterval(...

# from esx.esx import Date, String, Number
# etc..

You can use setInterval and clearInterval with params

from esx import setInterval, clearInterval

x=0

def hi(inc):
    global x
    x = x+inc
    print(x)

test = setInterval(hi, 1000, 2)
import time
time.sleep(5)
clearInterval(test)
print(f"Final value of x:{x}")

Or for a single delayed function call use setTimeout, clearTimeout

from esx import setTimeout, clearTimeout

timeoutID = setTimeout(hi, 1000)

DOCS

https://esx.readthedocs.io/

notes

Do some notes here

Join-In

Feel free to contribute if you find it useful.

Email me, message me directly if you like or create a discussion on here.

If there are any methods you want that are missing or not complete yet or you think you can help make it better just update the code and send a pull request.

I'll merge and releaese asap.

run tests

There are tests used during dev. They are useful as code examples and to see what still needs doing.

See Makefile to run all tests:

make test

or to test a single function:

python -m unittest tests.test_esx.TestCase.test_esx_array

or to test a whole module

python -m unittest tests.test_esx

to see coverage

coverage run -m unittest discover tests/
coverage report

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

esx-0.0.2.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

esx-0.0.2-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file esx-0.0.2.tar.gz.

File metadata

  • Download URL: esx-0.0.2.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for esx-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e10691ef0877d9604932e0e596f66802f1329c289e46cd381466e32708494ad2
MD5 10e1a969da9ed85104659bd2eba1d8c4
BLAKE2b-256 47686d3fa65eaf93c1b1a573ab526382522edda396da356c16be0874f58ee4b6

See more details on using hashes here.

File details

Details for the file esx-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: esx-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for esx-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d5910663566273f6b6d5ecc747aef9cd7b0cad17b5ba503cfd350825e8531766
MD5 2545c439a83dd1c6bc8d541aa7eebab2
BLAKE2b-256 5fcd32c93086e937bd10034bcfab5c85ba0c608fba4bc470ab6eb5928ab3015f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page