JSValue class
A JavaScript value. The base type for all JavaScript values, and polymorphic functions on them.
Constructors
-
JSValue(JSContext context, Pointer<
NativeType> pointer) - JSValue.makeBoolean(JSContext context, bool boolean)
-
Creates a JavaScript value of the boolean type.
boolean
The bool to assign to the newly created JSValue. - JSValue.makeFromJSONString(JSContext context, String string)
-
Creates a JavaScript value from a JSON formatted string.
string
The JSString containing the JSON string to be parsed. - JSValue.makeNull(JSContext context)
- Creates a JavaScript value of the null type.
- JSValue.makeNumber(JSContext context, double number)
-
Creates a JavaScript value of the number type.
number
The double to assign to the newly created JSValue. - JSValue.makeString(JSContext context, String string)
-
Creates a JavaScript value of the string type.
string
The double to assign to the newly created JSValue. - JSValue.makeSymbol(JSContext context, String description)
-
Creates a JavaScript value of the symbol type.
description
A description of the newly created symbol value. - JSValue.makeUndefined(JSContext context)
- Creates a JavaScript value of the undefined type.
Properties
- context → JSContext
-
JavaScript context
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- isArray → bool
-
Tests whether a JavaScript value is an array.
no setter
- isBoolean → bool
-
Tests whether a JavaScript value's type is the boolean type.
no setter
- isDate → bool
-
Tests whether a JavaScript value is a date.
no setter
- isNull → bool
-
Tests whether a JavaScript value's type is the null type.
no setter
- isNumber → bool
-
Tests whether a JavaScript value's type is the number type.
no setter
- isObject → bool
-
Tests whether a JavaScript value's type is the object type.
no setter
- isString → bool
-
Tests whether a JavaScript value's type is the string type.
no setter
- isSymbol → bool
-
Tests whether a JavaScript value's type is the symbol type.
no setter
- isUndefined → bool
-
Tests whether a JavaScript value's type is the undefined type.
no setter
-
pointer
→ Pointer<
NativeType> -
C pointer
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- string → String?
-
Converts a JavaScript value to number and returns the resulting string.
no setter
- toBoolean → bool
-
Converts a JavaScript value to boolean and returns the resulting boolean.
no setter
- type → JSType
-
Value type
no setter
Methods
-
createJSONString(
{int indent = 4, JSValuePointer? exception}) → JSString -
Creates a JavaScript string containing the JSON serialized representation of a JS value.
indent
The number of spaces to indent when nesting. If 0, the resulting JSON will not contains newlines. The size of the indent is clamped to 10 spaces.exception
A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. -
getTypedArrayType(
{JSValuePointer? exception}) → JSTypedArrayType - Returns a JavaScript value's Typed Array type.
-
isEqual(
JSValue other, {JSValuePointer? exception}) → bool - Tests whether two JavaScript values are equal, as compared by the JS == operator.
-
isInstanceOfConstructor(
JSObject constructor, {JSValuePointer? exception}) → bool - Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator.
-
isObjectOfClass(
JSClass jsClass) → bool -
Tests whether a JavaScript value's type is the symbol type.
jsClass
The JSClass to test against. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
protect(
) → void - Protects a JavaScript value from garbage collection. Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it.
-
toNumber(
{JSValuePointer? exception}) → double -
Converts a JavaScript value to number and returns the resulting number.
exception
A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. -
toObject(
{JSValuePointer? exception}) → JSObject -
Converts a JavaScript value to object and returns the resulting object.
exception
A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. -
toString(
) → String -
A string representation of this object.
inherited
-
toStringCopy(
{JSValuePointer? exception}) → JSString -
Converts a JavaScript value to string and copies the result into a JavaScript string.
exception
A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. -
unProtect(
) → void - Protects a JavaScript value from garbage collection. Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it.
Operators
-
operator ==(
Object other) → bool -
Tests whether two JavaScript values are strict equal, as compared by the JS === operator.
override
Static Methods
-
cEnumToJSType(
int typeCode) → JSType - C enum to enum JSType
-
cEnumToJSTypedArrayType(
int typeCode) → JSTypedArrayType - C enum to enum JSTypedArrayType
-
jSTypedArrayTypeToCEnum(
JSTypedArrayType type) → int - enum JSTypedArrayType to C enum
-
jSTypeToCEnum(
JSType type) → int - enum JSType to C enum