transform

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2023 License: MPL-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFunctionNotFound = errors.New("the transform function is not found, please define it or rename the existing function")
View Source
var ErrMaxExecutionTimeElapsed = errors.New("script execution time elapsed 10 seconds")

Functions

This section is empty.

Types

type BuffPrinter

type BuffPrinter struct {
	Buff         *strings.Builder
	BuffOutPrint func(s string)
	BuffErrPrint func(s string)
}

BuffPrinter implements the console.Printer interface that writes to a buffer.

func NewBufferPrinter

func NewBufferPrinter() *BuffPrinter

func (*BuffPrinter) Error

func (b *BuffPrinter) Error(s string)

Error writes s to a buffer.

func (*BuffPrinter) Format

func (b *BuffPrinter) Format() []string

func (*BuffPrinter) Log

func (b *BuffPrinter) Log(s string)

Log writes s to a buffer.

func (*BuffPrinter) Warn

func (b *BuffPrinter) Warn(s string)

Warn writes s to a buffer.

type Transformer

type Transformer struct {
	// contains filtered or unexported fields
}

func NewTransformer

func NewTransformer(r *goja.Runtime) *Transformer

func (*Transformer) RunStringUnsafe

func (t *Transformer) RunStringUnsafe(function string, payload interface{}) (interface{}, []string, error)

func (*Transformer) Transform

func (t *Transformer) Transform(function string, payload interface{}) (interface{}, []string, error)

Transform mutates the payload by the passed function The output of Transform should be idempotent

func (*Transformer) TransformUsingUnderscoreJs

func (t *Transformer) TransformUsingUnderscoreJs(function string, payload interface{}) (interface{}, []string, error)

TransformUsingUnderscoreJs downloads the underscore js library and then mutates the payload by the passed function. The output of TransformUsingUnderscoreJs should be idempotent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL