Skip to main content

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

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 mode: 执行模式, 默认以.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.5.tar.gz (4.6 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.5-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyevaljs3-0.0.5.tar.gz
  • Upload date:
  • Size: 4.6 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.5.tar.gz
Algorithm Hash digest
SHA256 e685fb5b2e95633f3d65a00b1427ebd48e8875de7d23389285e4dea1f63482e4
MD5 59e44a72de2ac60f8a361f724268661a
BLAKE2b-256 97de804abaf3bd5ddfd6cc636d7a3e81dcdedacf434322cfdd02e6de6c3e6dda

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyevaljs3-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.5 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5ccadb285d58e6919422f912589aa6a4cf88b1410ad6321f2c7743708b02ba9b
MD5 083bcea2535bc202e89935edea672c42
BLAKE2b-256 0a8f4201f45e31360f493dc8b87210d7ae923e092a70b58c5063d64fb1e85dbe

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