func celFmt()

in cmd/wasm/main.go [102:115]


func celFmt(_ js.Value, args []js.Value) any {
	if len(args) != 1 {
		return toObject(&celFmtResult{Error: "celFmt requires one argument"})
	}
	if args[0].Type() != js.TypeString {
		return toObject(&celFmtResult{Error: "celFmt argument must be a string"})
	}

	buf := new(bytes.Buffer)
	if err := compileAndFormat(buf, args[0].String()); err != nil {
		return toObject(&celFmtResult{Error: err.Error()})
	}
	return toObject(&celFmtResult{Formatted: buf.String()})
}