Skip to main content

JsTokenUtils

Assembly: ServiceStack.Common.dll
View Source
Declaration
public static class JsTokenUtils

Fields

NewLineUtf8

View Source
Declaration
public static readonly byte[] NewLineUtf8

OperatorPrecedence

View Source
Declaration
public static readonly Dictionary<string, int> OperatorPrecedence

Methods

GetBinaryPrecedence(String)

View Source
Declaration
public static int GetBinaryPrecedence(string token)
Returns

System.Int32

Parameters
TypeName
System.Stringtoken

IsNumericChar(Char)

View Source
Declaration
public static bool IsNumericChar(this char c)
Returns

System.Boolean

Parameters
TypeName
System.Charc

IsValidVarNameChar(Char)

View Source
Declaration
public static bool IsValidVarNameChar(this char c)
Returns

System.Boolean

Parameters
TypeName
System.Charc

IsOperatorChar(Char)

View Source
Declaration
public static bool IsOperatorChar(this char c)
Returns

System.Boolean

Parameters
TypeName
System.Charc

IsExpressionTerminatorChar(Char)

View Source
Declaration
public static bool IsExpressionTerminatorChar(this char c)
Returns

System.Boolean

Parameters
TypeName
System.Charc

GetUnaryOperator(Char)

View Source
Declaration
public static JsUnaryOperator GetUnaryOperator(this char c)
Returns

ServiceStack.Script.JsUnaryOperator

Parameters
TypeName
System.Charc

FirstCharEquals(ReadOnlySpan<Char>, Char)

View Source
Declaration
public static bool FirstCharEquals(this ReadOnlySpan<char> literal, char c)
Returns

System.Boolean

Parameters
TypeName
ReadOnlySpan<System.Char>literal
System.Charc

FirstCharEquals(String, Char)

View Source
Declaration
public static bool FirstCharEquals(this string literal, char c)
Returns

System.Boolean

Parameters
TypeName
System.Stringliteral
System.Charc

SafeGetChar(ReadOnlySpan<Char>, Int32)

View Source
Declaration
public static char SafeGetChar(this ReadOnlySpan<char> literal, int index)
Returns

System.Char

Parameters
TypeName
ReadOnlySpan<System.Char>literal
System.Int32index

CountPrecedingOccurrences(ReadOnlySpan<Char>, Int32, Char)

View Source
Declaration
public static int CountPrecedingOccurrences(this ReadOnlySpan<char> literal, int index, char c)
Returns

System.Int32

Parameters
TypeName
ReadOnlySpan<System.Char>literal
System.Int32index
System.Charc

SafeCharEquals(ReadOnlySpan<Char>, Int32, Char)

View Source
Declaration
public static bool SafeCharEquals(this ReadOnlySpan<char> literal, int index, char c)
Returns

System.Boolean

Parameters
TypeName
ReadOnlySpan<System.Char>literal
System.Int32index
System.Charc

AdvancePastPipeOperator(ReadOnlySpan<Char>)

View Source
Declaration
public static ReadOnlySpan<char> AdvancePastPipeOperator(this ReadOnlySpan<char> literal)
Returns

ReadOnlySpan<System.Char>

Parameters
TypeName
ReadOnlySpan<System.Char>literal

SafeGetChar(ReadOnlyMemory<Char>, Int32)

View Source
Declaration
public static char SafeGetChar(this ReadOnlyMemory<char> literal, int index)
Returns

System.Char

Parameters
TypeName
ReadOnlyMemory<System.Char>literal
System.Int32index

IsEnd(Char)

View Source
Declaration
public static bool IsEnd(this char c)
Returns

System.Boolean

Parameters
TypeName
System.Charc

Chop(ReadOnlyMemory<Char>, Char)

View Source
Declaration
public static ReadOnlyMemory<char> Chop(this ReadOnlyMemory<char> literal, char c)
Returns

ReadOnlyMemory<System.Char>

Parameters
TypeName
ReadOnlyMemory<System.Char>literal
System.Charc

Chop(ReadOnlySpan<Char>, Char)

View Source
Declaration
public static ReadOnlySpan<char> Chop(this ReadOnlySpan<char> literal, char c)
Returns

ReadOnlySpan<System.Char>

Parameters
TypeName
ReadOnlySpan<System.Char>literal
System.Charc

ChopNewLine(ReadOnlyMemory<Char>)

View Source
Declaration
public static ReadOnlyMemory<char> ChopNewLine(this ReadOnlyMemory<char> literal)
Returns

ReadOnlyMemory<System.Char>

Parameters
TypeName
ReadOnlyMemory<System.Char>literal

ToJsAstType(Type)

View Source
Declaration
public static string ToJsAstType(this Type type)
Returns

System.String

Parameters
TypeName
System.Typetype

ToJsAst(JsToken)

View Source
Declaration
public static Dictionary<string, object> ToJsAst(this JsToken token)
Returns

System.Collections.Generic.Dictionary<System.String,System.Object>

Parameters
TypeName
ServiceStack.Script.JsTokentoken

ToJsAstString(JsToken)

View Source
Declaration
public static string ToJsAstString(this JsToken token)
Returns

System.String

Parameters
TypeName
ServiceStack.Script.JsTokentoken

Evaluate(JsToken)

View Source
Declaration
public static object Evaluate(this JsToken token)
Returns

System.Object

Parameters
TypeName
ServiceStack.Script.JsTokentoken

EvaluateToBool(JsToken, ScriptScopeContext)

View Source
Declaration
public static bool EvaluateToBool(this JsToken token, ScriptScopeContext scope)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Script.JsTokentoken
ServiceStack.Script.ScriptScopeContextscope

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
Declaration
public static async Task<bool> EvaluateToBoolAsync(this JsToken token, ScriptScopeContext scope)
Returns

System.Threading.Tasks.Task<System.Boolean>

Parameters
TypeName
ServiceStack.Script.JsTokentoken
ServiceStack.Script.ScriptScopeContextscope

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
Declaration
public static bool EvaluateToBool(this JsToken token, ScriptScopeContext scope, out bool? result, out Task<bool> asyncResult)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Script.JsTokentoken
ServiceStack.Script.ScriptScopeContextscope
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
Declaration
public static Task<object> EvaluateAsync(this JsToken token, ScriptScopeContext scope)
Returns

System.Threading.Tasks.Task<System.Object>

Parameters
TypeName
ServiceStack.Script.JsTokentoken
ServiceStack.Script.ScriptScopeContextscope

Evaluate(JsToken, ScriptScopeContext, out Object, out Task<Object>)

Evaluate then set asyncResult if Result was async, otherwise set result.

View Source
Declaration
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
TypeName
ServiceStack.Script.JsTokentoken
ServiceStack.Script.ScriptScopeContextscope
System.Objectresult
System.Threading.Tasks.Task<System.Object>asyncResult

ParseJsToken(ReadOnlySpan<Char>, out JsToken)

View Source
Declaration
public static ReadOnlySpan<char> ParseJsToken(this ReadOnlySpan<char> literal, out JsToken token)
Returns

ReadOnlySpan<System.Char>

Parameters
TypeName
ReadOnlySpan<System.Char>literal
ServiceStack.Script.JsTokentoken

ParseJsToken(ReadOnlySpan<Char>, out JsToken, Boolean)

View Source
Declaration
public static ReadOnlySpan<char> ParseJsToken(this ReadOnlySpan<char> literal, out JsToken token, bool filterExpression)
Returns

ReadOnlySpan<System.Char>

Parameters
TypeName
ReadOnlySpan<System.Char>literal
ServiceStack.Script.JsTokentoken
System.BooleanfilterExpression

IndexOfQuotedString(ReadOnlySpan<Char>, Char, out Boolean)

View Source
Declaration
public static int IndexOfQuotedString(this ReadOnlySpan<char> literal, char quoteChar, out bool hasEscapeChars)
Returns

System.Int32

Parameters
TypeName
ReadOnlySpan<System.Char>literal
System.CharquoteChar
System.BooleanhasEscapeChars

ParseArgumentsList(ReadOnlySpan<Char>, out List<JsIdentifier>)

View Source
Declaration
public static ReadOnlySpan<char> ParseArgumentsList(this ReadOnlySpan<char> literal, out List<JsIdentifier> args)
Returns

ReadOnlySpan<System.Char>

Parameters
TypeName
ReadOnlySpan<System.Char>literal
System.Collections.Generic.List<ServiceStack.Script.JsIdentifier>args

ParseVarName(ReadOnlySpan<Char>, out ReadOnlySpan<Char>)

View Source
Declaration
public static ReadOnlySpan<char> ParseVarName(this ReadOnlySpan<char> literal, out ReadOnlySpan<char> varName)
Returns

ReadOnlySpan<System.Char>

Parameters
TypeName
ReadOnlySpan<System.Char>literal
ReadOnlySpan<System.Char>varName

ParseVarName(ReadOnlyMemory<Char>, out ReadOnlyMemory<Char>)

View Source
Declaration
public static ReadOnlyMemory<char> ParseVarName(this ReadOnlyMemory<char> literal, out ReadOnlyMemory<char> varName)
Returns

ReadOnlyMemory<System.Char>

Parameters
TypeName
ReadOnlyMemory<System.Char>literal
ReadOnlyMemory<System.Char>varName