Skip to main content

ECMAScript code generator

Project description

Escodegen (escodegen) is an ECMAScript (also popularly known as JavaScript) code generator from Mozilla's Parser API AST. See the online generator for a demo. This repository contains the Python translation of Escodegen.

Install

pip install escodegen

Usage

Example:

import escodegen

escodegen.generate({
    'type': 'BinaryExpression',
    'operator': '+',
    'left': { 'type': 'Literal', 'value': 20 },
    'right': { 'type': 'Literal', 'value': 2 }
})

produces the string: '20 + 2'

Example:

import escodegen
import esprima

escodegen.generate(esprima.parse('let a=10;let b=20'))

produces the string: 'let a = 10;\nlet b = 20;'

See the API page for options.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

escodegen-1.0.11-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file escodegen-1.0.11-py3-none-any.whl.

File metadata

  • Download URL: escodegen-1.0.11-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.7

File hashes

Hashes for escodegen-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 2e46fbbef86faf175165c8ebaa2207b1ee5624918ee9e1daf67fa247d2dbb074
MD5 2f557db558d6eb38647c0b145a48cca3
BLAKE2b-256 bf339d9637765f4f024740185e5ebaae28acdaa9d54b831d3bb6a11a82834447

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