Joe
type (joe
)
The Joe
singleton collects a variety of useful functions
related to the interpreter itself and to the installed
Joe types.
- Joe.compare(a, b) → Number
- Joe.currentTimeMillis() → Number
- Joe.getFieldNames(value) → List
- Joe.isFact(value) → Boolean
- Joe.isOpaque(value) → Boolean
- Joe.isType(value) → Boolean
- Joe.stringify(value) → String
- Joe.supertypeOf(type) → type
- Joe.toFact(value) → Fact
- Joe.typeOf(value) → type
Static Methods
Joe.compare()
Joe.compare(a, b) → Number
Given two strings or two numbers a and b, returns -1, 0, or 1 as a < b, a == b, or a > b. This function is useful when sorting collections.
Joe.currentTimeMillis()
Joe.currentTimeMillis() → Number
Returns Java's System.currentTimeMillis()
, the current time in
milliseconds since the epoch.
Joe.getFieldNames()
Joe.getFieldNames(value) → List
Returns a read-only list of the names of the fields defined on the value.
If the value has no fields, this method returns the empty list.
If the value is a Joe type, this method returns the names of the type's static fields.
Note: There is no way to know the names of an
instance's fields just by looking at its type, generally speaking.
Distinct instances of the same Joe class
might have different
fields.
Joe.isFact()
Joe.isFact(value) → Boolean
Returns true if the value can be used as a Nero Fact
, and
false otherwise.
Joe.isOpaque()
Joe.isOpaque(value) → Boolean
Returns true if the value is of an opaque type, and false otherwise. An opaque type is a Java type with no defined Joe binding.
Joe.isType()
Joe.isType(value) → Boolean
Returns true if the value represents a Joe type, e.g.,
the String
type or a Joe class
, and false otherwise.
Joe.stringify()
Joe.stringify(value) → String
Converts its value to a string for output. This function
is functionally equivalent to String()
, or to
value.toString()
(if the type defines a toString()
method).
It is rare to need to call this function directly, but it is available if needed.
Joe.supertypeOf()
Joe.supertypeOf(type) → type
Returns the supertype of the given type, or null if the type has no supertype.
Joe.toFact()
Joe.toFact(value) → Fact
Returns the value as a Nero Fact
.
Throws an Error
if !isFact(value)
.
Joe.typeOf()
Joe.typeOf(value) → type
Returns the Joe type of the given value.