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 hashes)

Uploaded Python 3

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