gssjs

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gssjs includes functions for the JavaScript build of GSS.

Index

Constants

View Source
const (
	NoLimit = -1
)

Variables

View Source
var (
	ErrMissingInputString  = errors.New("missing input string")
	ErrMissingInputObject  = errors.New("missing input object")
	ErrMissingInputFormat  = errors.New("missing input format")
	ErrMissingOutputFormat = errors.New("missing output format")
)
View Source
var (
	DeserializeDefaults = map[string]interface{}{
		"limit":             NoLimit,
		"keyValueSeparator": "=",
		"lineSeparator":     "\n",
		"escapePrefix":      "\\",
		"expandHeader":      true,
	}
	SerializeDefaults = map[string]interface{}{
		"limit":             NoLimit,
		"keyValueSeparator": "=",
		"lineSeparator":     "\n",
		"escapePrefix":      "\\",
	}
)
View Source
var Exports = map[string]interface{}{
	"formats": serializer.Formats,
	"convert": func(inputString string, inputFormat string, outputFormat string, inputOptions map[string]interface{}, outputOptions map[string]interface{}) map[string]interface{} {
		str, err := Convert(inputString, inputFormat, outputFormat, inputOptions, outputOptions)
		if err != nil {
			return map[string]interface{}{"str": nil, "err": errors.Wrap(err, "error converting input string").Error()}
		}
		return map[string]interface{}{"str": str, "err": nil}
	},
	"deserialize": func(inputString string, inputFormat string, options map[string]interface{}) map[string]interface{} {
		obj, err := Deserialize(inputString, inputFormat, options)
		if err != nil {
			return map[string]interface{}{"obj": nil, "err": errors.Wrap(err, "error deserializing input string").Error()}
		}
		return map[string]interface{}{"obj": obj, "err": nil}
	},
	"serialize": func(inputObject *js.Object, outputFormat string, options map[string]interface{}) map[string]interface{} {
		str, err := Serialize(parseObject(inputObject), outputFormat, options)
		if err != nil {
			return map[string]interface{}{"str": nil, "err": errors.Wrap(err, "error serializing input object").Error()}
		}
		return map[string]interface{}{"str": str, "err": nil}
	},
}

Functions

func Convert

func Convert(inputString string, inputFormat string, outputFormat string, deserializeOptions map[string]interface{}, serializeOptions map[string]interface{}) (string, error)

Convert is a function provided to gss.js that wraps gss.Convert to support JavaScript.

func Deserialize

func Deserialize(inputString string, inputFormat string, options map[string]interface{}) (interface{}, error)

Deserialize is a function provided to gss.js that wraps gss.Deserialize to support JavaScript. func Deserialize(inputString string, inputFormat string, options *js.Object) interface{} {

func Serialize

func Serialize(inputObject interface{}, outputFormat string, options map[string]interface{}) (string, error)

Serialize is a function provided to gss.js that wraps gss.Serialize to support JavaScript. func Serialize(inputObject interface{}, outputFormat string, options *js.Object) interface{} {

Types

This section is empty.

Jump to

Keyboard shortcuts

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