Documentation ¶
Overview ¶
expressiongenerator defines code for translating from CodeDOM expressions into esbuilder ExpressionBuilder objects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncOption ¶
type AsyncOption int
AsyncOption defines the various options around asynchrounous expression generation.
const ( // AllowedSync indicates that GenerateExpression can return a synchronous expression. AllowedSync AsyncOption = iota // EnsureAsync indicates that GenerateExpression must return an asynchronous expression. // If the provided expression is synchronous, it will be wrapped in a new promise. EnsureAsync )
type ByKey ¶
type ByKey []codedom.ObjectLiteralEntryNode
ByKey is a helper to sort ObjectLiteralEntryNode's.
type ExpressionResult ¶
type ExpressionResult struct {
// contains filtered or unexported fields
}
ExpressionResult represents the result of generating an expression.
func GenerateExpression ¶
func GenerateExpression(expression codedom.Expression, asyncOption AsyncOption, scopegraph *scopegraph.ScopeGraph, machineBuilder StateMachineBuilder) ExpressionResult
GenerateExpression generates the full ES5 expression for the given CodeDOM expression representation.
func (ExpressionResult) Build ¶
func (er ExpressionResult) Build() esbuilder.SourceBuilder
Build returns the builder for this expression.
func (ExpressionResult) BuildWrapped ¶
func (er ExpressionResult) BuildWrapped(wrappingTemplateStr string, data interface{}) esbuilder.SourceBuilder
BuildWrapped returns the builder for this expression. If specified, the expression will be wrapped via the given template string. The original expression builder reference will be placed into a template field with name "ResultExpr", while any data passed into this method will be placed into "Data".
func (ExpressionResult) IsAsync ¶
func (er ExpressionResult) IsAsync() bool
IsAsync returns true if the generated expression is asynchronous.
func (ExpressionResult) Variables ¶
func (er ExpressionResult) Variables() []string
Variables returns the names of all variables generated by the expression.
type StateMachineBuilder ¶
type StateMachineBuilder func(body codedom.StatementOrExpression, functionTraits shared.StateFunctionTraits) esbuilder.SourceBuilder