Home Reference Source Repository

Function

Static Public Summary
public

fromObject(_: *): *

Converts a plain object to a {@link Node}.
public

functionExpressionThunk(body: *, generator: *): *

public
Mangles name and makes an {@link Identifier}.
public

loc(ast: Node, loc: Loc): *

Assigns `loc` to `ast` and returns it.
public
Convert a name to a valid JavaScript identifier.
public

member(object: Node, propertyName: string): MemberExpression

Creates a member expression for `propertyName` in `object`, using dot syntax (`a.b`) if possible, and falling back to `a['b']`.
public

needsMangle(name: *): *

`false` iff `name` is a valid JavaScript identifier.
public
An Identifier if propertyName is a valid JavaScript property name; otherwise a Literal string.
public

propertyNameOk(name: *): *

`true` iff `name` can be used as a property name using dot syntax (`a.b`).
public

render(ast: Node, options: object): *

Creates JavaScript source code from a {@link Node}.
public

renderWithSourceMap(ast: Node, inFilePath: string, outFilePath: string): code: string, sourceMap: string

Same as {@link render}, but with a source map as part of the output.
public

singleCharLoc(pos: Pos): *

Loc consisting of the character at `pos`.
public

toStatement(ast: *): *

Convert any {@link Node} into one that can be used as the content of a line.
public

unmangle(name: *): *

Undoes {@link mangleIdentifier}.

Static Public

public fromObject(_: *): * source

import fromObject from 'esast/src/fromJson.js'

Converts a plain object to a Node.

Params:

NameTypeAttributeDescription
_ *

Return:

*

public functionExpressionThunk(body: *, generator: *): * source

import {functionExpressionThunk} from 'esast/src/util.js'

Params:

NameTypeAttributeDescription
body *
generator *

Return:

*

public identifier(name: string): Identifier source

import {identifier} from 'esast/src/util.js'

Mangles name and makes an Identifier.

Params:

NameTypeAttributeDescription
name string

Return:

Identifier

public loc(ast: Node, loc: Loc): * source

import {loc} from 'esast/src/util.js'

Assigns loc to ast and returns it.

Params:

NameTypeAttributeDescription
ast Node
loc Loc

Return:

*

public mangleIdentifier(name: String): String source

import mangleIdentifier from 'esast/src/mangle-identifier.js'

Convert a name to a valid JavaScript identifier.

Params:

NameTypeAttributeDescription
name String

Can be any string.

Return:

String

public member(object: Node, propertyName: string): MemberExpression source

import {member} from 'esast/src/util.js'

Creates a member expression for propertyName in object, using dot syntax (a.b) if possible, and falling back to a['b'].

Params:

NameTypeAttributeDescription
object Node
propertyName string

public needsMangle(name: *): * source

import {needsMangle} from 'esast/src/mangle-identifier.js'

false iff name is a valid JavaScript identifier.

Params:

NameTypeAttributeDescription
name *

Return:

*

public propertyIdOrLiteral(propertyName: string): Identifier | Literal source

import {propertyIdOrLiteral} from 'esast/src/util.js'

An Identifier if propertyName is a valid JavaScript property name; otherwise a Literal string.

Params:

NameTypeAttributeDescription
propertyName string

Return:

Identifier | Literal

public propertyNameOk(name: *): * source

import {propertyNameOk} from 'esast/src/mangle-identifier.js'

true iff name can be used as a property name using dot syntax (a.b).

Params:

NameTypeAttributeDescription
name *

Return:

*

public render(ast: Node, options: object): * source

import render from 'esast/src/render.js'

Creates JavaScript source code from a Node.

Params:

NameTypeAttributeDescription
ast Node
options object
options.ugly boolean

If true, will not output any whitespace.

Return:

*

public renderWithSourceMap(ast: Node, inFilePath: string, outFilePath: string): code: string, sourceMap: string source

import {renderWithSourceMap} from 'esast/src/render.js'

Same as render, but with a source map as part of the output.

Params:

NameTypeAttributeDescription
ast Node
inFilePath string

Name of input file.

outFilePath string

Name of output file.

. object

Return:

code: string, sourceMap: string

public singleCharLoc(pos: Pos): * source

import {singleCharLoc} from 'esast/src/Loc.js'

Loc consisting of the character at pos.

Params:

NameTypeAttributeDescription
pos Pos

Return:

*

public toStatement(ast: *): * source

import {toStatement} from 'esast/src/util.js'

Convert any Node into one that can be used as the content of a line. (esast requires all expression lines to be wrapped with ExpressionStatement.)

Params:

NameTypeAttributeDescription
ast *

Return:

*

public unmangle(name: *): * source

import {unmangle} from 'esast/src/mangle-identifier.js'

Undoes mangleIdentifier.

Params:

NameTypeAttributeDescription
name *

Return:

*