github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/types/lib.go (about) 1 package types 2 3 import ( 4 "github.com/MontFerret/ferret/pkg/runtime/core" 5 "github.com/MontFerret/ferret/pkg/runtime/values" 6 ) 7 8 func RegisterLib(ns core.Namespace) error { 9 return ns.RegisterFunctions( 10 core.NewFunctionsFromMap(map[string]core.Function{ 11 "TO_BOOL": ToBool, 12 "TO_INT": ToInt, 13 "TO_FLOAT": ToFloat, 14 "TO_STRING": ToString, 15 "TO_DATETIME": ToDateTime, 16 "TO_ARRAY": ToArray, 17 "TO_BINARY": ToBinary, 18 "IS_NONE": IsNone, 19 "IS_BOOL": IsBool, 20 "IS_INT": IsInt, 21 "IS_FLOAT": IsFloat, 22 "IS_STRING": IsString, 23 "IS_DATETIME": IsDateTime, 24 "IS_ARRAY": IsArray, 25 "IS_OBJECT": IsObject, 26 "IS_HTML_ELEMENT": IsHTMLElement, 27 "IS_HTML_DOCUMENT": IsHTMLDocument, 28 "IS_BINARY": IsBinary, 29 "IS_NAN": IsNaN, 30 "TYPENAME": TypeName, 31 })) 32 } 33 34 func isTypeof(value core.Value, ctype core.Type) core.Value { 35 return values.NewBoolean(core.IsTypeOf(value, ctype)) 36 }