-
Notifications
You must be signed in to change notification settings - Fork 336
escodegen.generate(AST[, options]);
{
format: {
indent: {
style: ' ',
base: 0
},
json: false,
renumber: false,
hexadecimal: false,
quotes: 'single',
escapeless: false,
compact: false,
parentheses: true,
semicolons: true
},
parse: null,
comment: false,
sourceMap: undefined
}
-
option.format.indent.style
: Indent string. Default is 4 spaces (' '). -
option.format.indent.base
: Base indent level. Default is 0. -
option.format.json
: Enforce JSON format of numeric and string literals. This option takes precedence overoption.format.hexadecimal
andoption.format.quotes
. Default is false. -
option.format.renumber
: Try to generate shorter numeric literals than toString() (9.8.1). Default is false. -
option.format.hexadecimal
: Generate hexadecimal a numeric literal if it is shorter than its equivalents. Requiresoption.format.renumber
. Default is false. -
option.format.quotes
: Delimiter to use for string literals. Accepted values are: 'single', 'double', and 'auto'. When 'auto' is specified, escodegen selects a delimiter that results in a shorter literal. Default is 'single'. -
option.format.escapeless
: Escape as few characters in string literals as necessary. Default is false. -
option.format.compact
: Do not include superfluous whitespace characters and line terminators. Default is false. -
option.format.parentheses
: Preserve parentheses in new expressions that have no arguments. Default is true. -
option.format.semicolons
: Preserve semicolons at the end of blocks and programs. Default is true. -
option.parse
: Mozilla Parser API compatible parse function. If it is provided, generator tries to use the 'raw' representation. See esprima raw information. Default is null. -
option.comment
: If comments are attached to AST, escodegen is going to emit comments to output code. Default is false. -
option.sourceMap
,option.sourceMapRoot
andoption.sourceMapWithCode
:sourceMap
is the source maps's source filename. If a non-empty string value is provided, generate a source map, using the given string as the filename for the generated source that the source map is associated with. For more information about source map itself, see source map library document, V3 draft and HTML5Rocks introduction. Default isundefined
.sourceMapRoot
is the source root for the source map (see the Mozilla documentation). IfsourceMapWithCode
is truthy, an object is returned fromgenerate()
of the form:{ code: .. , map: .. }
.