JsTokenUtils
Assembly: ServiceStack.Common.dll
View Source
public static class JsTokenUtils
Fields
NewLineUtf8
View Source
public static readonly byte[] NewLineUtf8
OperatorPrecedence
View Source
public static readonly Dictionary<string, int> OperatorPrecedence
Methods
GetBinaryPrecedence(String)
View Source
public static int GetBinaryPrecedence(string token)
Returns
System.Int32
Parameters
Type | Name |
---|---|
System.String | token |
IsNumericChar(Char)
View Source
public static bool IsNumericChar(this char c)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Char | c |
IsValidVarNameChar(Char)
View Source
public static bool IsValidVarNameChar(this char c)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Char | c |
IsOperatorChar(Char)
View Source
public static bool IsOperatorChar(this char c)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Char | c |
IsExpressionTerminatorChar(Char)
View Source
public static bool IsExpressionTerminatorChar(this char c)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Char | c |
GetUnaryOperator(Char)
View Source
public static JsUnaryOperator GetUnaryOperator(this char c)
Returns
ServiceStack.Script.JsUnaryOperator
Parameters
Type | Name |
---|---|
System.Char | c |
FirstCharEquals(ReadOnlySpan<Char>, Char)
View Source
public static bool FirstCharEquals(this ReadOnlySpan<char> literal, char c)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
System.Char | c |
FirstCharEquals(String, Char)
View Source
public static bool FirstCharEquals(this string literal, char c)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.String | literal |
System.Char | c |
SafeGetChar(ReadOnlySpan<Char>, Int32)
View Source
public static char SafeGetChar(this ReadOnlySpan<char> literal, int index)
Returns
System.Char
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
System.Int32 | index |
CountPrecedingOccurrences(ReadOnlySpan<Char>, Int32, Char)
View Source
public static int CountPrecedingOccurrences(this ReadOnlySpan<char> literal, int index, char c)
Returns
System.Int32
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
System.Int32 | index |
System.Char | c |
SafeCharEquals(ReadOnlySpan<Char>, Int32, Char)
View Source
public static bool SafeCharEquals(this ReadOnlySpan<char> literal, int index, char c)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
System.Int32 | index |
System.Char | c |
AdvancePastPipeOperator(ReadOnlySpan<Char>)
View Source
public static ReadOnlySpan<char> AdvancePastPipeOperator(this ReadOnlySpan<char> literal)
Returns
ReadOnlySpan<System.Char>
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
SafeGetChar(ReadOnlyMemory<Char>, Int32)
View Source
public static char SafeGetChar(this ReadOnlyMemory<char> literal, int index)
Returns
System.Char
Parameters
Type | Name |
---|---|
ReadOnlyMemory<System.Char> | literal |
System.Int32 | index |
IsEnd(Char)
View Source
public static bool IsEnd(this char c)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
System.Char | c |
Chop(ReadOnlyMemory<Char>, Char)
View Source
public static ReadOnlyMemory<char> Chop(this ReadOnlyMemory<char> literal, char c)
Returns
ReadOnlyMemory<System.Char>
Parameters
Type | Name |
---|---|
ReadOnlyMemory<System.Char> | literal |
System.Char | c |
Chop(ReadOnlySpan<Char>, Char)
View Source
public static ReadOnlySpan<char> Chop(this ReadOnlySpan<char> literal, char c)
Returns
ReadOnlySpan<System.Char>
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
System.Char | c |
ChopNewLine(ReadOnlyMemory<Char>)
View Source
public static ReadOnlyMemory<char> ChopNewLine(this ReadOnlyMemory<char> literal)
Returns
ReadOnlyMemory<System.Char>
Parameters
Type | Name |
---|---|
ReadOnlyMemory<System.Char> | literal |
ToJsAstType(Type)
View Source
public static string ToJsAstType(this Type type)
Returns
System.String
Parameters
Type | Name |
---|---|
System.Type | type |
ToJsAst(JsToken)
View Source
public static Dictionary<string, object> ToJsAst(this JsToken token)
Returns
System.Collections.Generic.Dictionary<System.String,System.Object>
Parameters
Type | Name |
---|---|
ServiceStack.Script.JsToken | token |
ToJsAstString(JsToken)
View Source
public static string ToJsAstString(this JsToken token)
Returns
System.String
Parameters
Type | Name |
---|---|
ServiceStack.Script.JsToken | token |
Evaluate(JsToken)
View Source
public static object Evaluate(this JsToken token)
Returns
System.Object
Parameters
Type | Name |
---|---|
ServiceStack.Script.JsToken | token |
EvaluateToBool(JsToken, ScriptScopeContext)
View Source
public static bool EvaluateToBool(this JsToken token, ScriptScopeContext scope)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
ServiceStack.Script.JsToken | token |
ServiceStack.Script.ScriptScopeContext | scope |
EvaluateToBoolAsync(JsToken, ScriptScopeContext)
Evaluate if result can be async, if so converts async result to Task<object> otherwise wraps result in a Task
View Source
public static async Task<bool> EvaluateToBoolAsync(this JsToken token, ScriptScopeContext scope)
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
Type | Name |
---|---|
ServiceStack.Script.JsToken | token |
ServiceStack.Script.ScriptScopeContext | scope |
EvaluateToBool(JsToken, ScriptScopeContext, out Nullable<Boolean>, out Task<Boolean>)
Evaluate if result can be async, if so converts async result to Task<object> otherwise wraps result in a Task
View Source
public static bool EvaluateToBool(this JsToken token, ScriptScopeContext scope, out bool? result, out Task<bool> asyncResult)
Returns
System.Boolean
Parameters
Type | Name |
---|---|
ServiceStack.Script.JsToken | token |
ServiceStack.Script.ScriptScopeContext | scope |
System.Nullable<System.Boolean> | result |
System.Threading.Tasks.Task<System.Boolean> | asyncResult |
EvaluateAsync(JsToken, ScriptScopeContext)
Evaluate if result can be async, if so converts async result to Task<object> otherwise wraps result in a Task
View Source
public static Task<object> EvaluateAsync(this JsToken token, ScriptScopeContext scope)
Returns
System.Threading.Tasks.Task<System.Object>
Parameters
Type | Name |
---|---|
ServiceStack.Script.JsToken | token |
ServiceStack.Script.ScriptScopeContext | scope |
Evaluate(JsToken, ScriptScopeContext, out Object, out Task<Object>)
Evaluate then set asyncResult if Result was async, otherwise set result.
View Source
public static bool Evaluate(this JsToken token, ScriptScopeContext scope, out object result, out Task<object> asyncResult)
Returns
System.Boolean
: true if result was synchronous otherwise false
Parameters
Type | Name |
---|---|
ServiceStack.Script.JsToken | token |
ServiceStack.Script.ScriptScopeContext | scope |
System.Object | result |
System.Threading.Tasks.Task<System.Object> | asyncResult |
ParseJsToken(ReadOnlySpan<Char>, out JsToken)
View Source
public static ReadOnlySpan<char> ParseJsToken(this ReadOnlySpan<char> literal, out JsToken token)
Returns
ReadOnlySpan<System.Char>
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
ServiceStack.Script.JsToken | token |
ParseJsToken(ReadOnlySpan<Char>, out JsToken, Boolean)
View Source
public static ReadOnlySpan<char> ParseJsToken(this ReadOnlySpan<char> literal, out JsToken token, bool filterExpression)
Returns
ReadOnlySpan<System.Char>
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
ServiceStack.Script.JsToken | token |
System.Boolean | filterExpression |
IndexOfQuotedString(ReadOnlySpan<Char>, Char, out Boolean)
View Source
public static int IndexOfQuotedString(this ReadOnlySpan<char> literal, char quoteChar, out bool hasEscapeChars)
Returns
System.Int32
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
System.Char | quoteChar |
System.Boolean | hasEscapeChars |
ParseArgumentsList(ReadOnlySpan<Char>, out List<JsIdentifier>)
View Source
public static ReadOnlySpan<char> ParseArgumentsList(this ReadOnlySpan<char> literal, out List<JsIdentifier> args)
Returns
ReadOnlySpan<System.Char>
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
System.Collections.Generic.List<ServiceStack.Script.JsIdentifier> | args |
ParseVarName(ReadOnlySpan<Char>, out ReadOnlySpan<Char>)
View Source
public static ReadOnlySpan<char> ParseVarName(this ReadOnlySpan<char> literal, out ReadOnlySpan<char> varName)
Returns
ReadOnlySpan<System.Char>
Parameters
Type | Name |
---|---|
ReadOnlySpan<System.Char> | literal |
ReadOnlySpan<System.Char> | varName |
ParseVarName(ReadOnlyMemory<Char>, out ReadOnlyMemory<Char>)
View Source
public static ReadOnlyMemory<char> ParseVarName(this ReadOnlyMemory<char> literal, out ReadOnlyMemory<char> varName)
Returns
ReadOnlyMemory<System.Char>
Parameters
Type | Name |
---|---|
ReadOnlyMemory<System.Char> | literal |
ReadOnlyMemory<System.Char> | varName |