Skip to main content

一个依赖node.js来执行js代码的库

Project description

一个依赖node.js来执行js代码的库


环境

注意 需要安装好node.js!!!


安装

pip install pyevaljs3

快速开始

import pyevaljs3

js_code = "console.log(100); return 'ok';"
js_eval = pyevaljs3.JSEval()
js_eval.eval(js_code)

API参考

pyevaljs3.JSEval

  • def compile(self, source: str = None, suffix: str = None):
       编译javascript源代码
       :param source: 源代码字符串或要读取的文件路径
       :param suffix: js脚本文件名后缀(指定以什么模式执行), 默认是".js", 可选的值还有".cjs", ".mjs"等
       :return: Context
  • def eval(self, code: str = None):
       执行javascript代码, 返回其结果(对于长字符串的情况,请使用compile)

pyevaljs3.Context

  • def call(self, func, *args):
       调用指定的函数, 返回其结果
       :param func: 函数名
       :param args: 函数的参数列表

pyevaljs3的模块级函数

  • def compile_(source: str = None, mode: str = None) -> Context:
       编译js源代码
       :param source: 源代码字符串或要读取的文件路径
       :param suffix: 执行模式, 默认以.js的行为去执行
       :return: Context

  • def eval_(code: str = None):
       执行javascript代码, 返回其结果(对于长字符串的情况,请使用compile)
       :param code: js代码


欢迎各位使用此库, 有问题请提交issue

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

pyevaljs3-0.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyevaljs3-0.0.2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyevaljs3-0.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.7

File hashes

Hashes for pyevaljs3-0.0.2.tar.gz
Algorithm Hash digest
SHA256 11577f9f73f1704c4c688f177549f4a6e5469ccc25f76f99120ecce327f166f7
MD5 b90b76ff0f5b5ab577a778df6c6f3b95
BLAKE2b-256 38ab4c4d36bd68fac8193f49b2e5f06872e66081573f5131e4bbe6cb5eb530b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyevaljs3-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.7

File hashes

Hashes for pyevaljs3-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c13088a1dc5978df40f6294edcd895ab97261f09847d569a20352d37606a22dd
MD5 7353b55c79c3c90a6606441f3e168b22
BLAKE2b-256 c6f21f7b2e56a5dbb356453887beb8b9e49677279058e1ec1d269789fad80d55

See more details on using hashes here.

Supported by

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