// NewJavascriptBuilder compiles the supplied javascript and creates a Javascriptbulder
NewJavascriptBuilder compiles the supplied javascript and creates a Javascriptbulder
// NewJavascriptBuilder compiles the supplied javascript and creates a Javascriptbulder
func NewJavascriptBuilder(config Config, file, src string) (*JavascriptBuilder, error) {
	js := &JavascriptBuilder{
		file:      file,
		vm:        otto.New(),
		path:      filepath.Dir(file),
		config:    config,
		nodes:     make(map[string]Node),
		pipelines: make([]*transporter.Pipeline, 0),
	}
	var (
		script *otto.Script
		err    error
	)
	if src != "" {
		script, err = js.vm.Compile("", src)
	} else {
		script, err = js.vm.Compile(file, nil)
	}
	if err != nil {
		return js, err
	}
	js.script = script
	js.vm.Set("Source", js.source)
	return js, nil
}
func NewJavascriptBuilder ( config Config , file , src string ) ( * JavascriptBuilder , error ) { js := & JavascriptBuilder { file : file , vm : otto . New ( ) , path : filepath . Dir ( file ) , config : config , nodes : make ( map [ string ] Node ) , pipelines : make ( [ ] * transporter . Pipeline , 0 ) , } var ( script * otto . Script err error ) if src != " " { script , err = js . vm . Compile ( " " , src ) } else { script , err = js . vm . Compile ( file , nil ) } if err != nil { return js , err } js . script = script js . vm . Set ( " " , js . source ) return js , nil }
NewJavascriptBuilder compiles the supplied javascript and creates a Javascriptbulder
NewJavascriptBuilder compiles the supplied javascript and creates a Javascriptbulder