Package io.karatelabs.js
Class CallInfo
java.lang.Object
io.karatelabs.js.CallInfo
Provides reflection-like awareness for callables about their invocation context.
This solves the JavaScript quirk where built-in constructors like Number, String, and Boolean behave differently when called with vs without the 'new' keyword:
Number(5)returns primitive 5new Number(5)returns a boxed Number object
Callables can check context.getCallInfo() to determine how they were invoked
and return the appropriate value. For normal function calls, getCallInfo()
returns null (no overhead). CallInfo is only created for special invocation contexts.
Future extensions could include:
- Tracking
.call()and.apply()invocations - Supporting proper Date, Promise, or RegExp construction
- Enabling better error messages with call-site information
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal ObjectThe function or callable being invokedfinal booleanTrue if invoked with the 'new' keyword -
Method Summary
-
Field Details
-
constructor
public final boolean constructorTrue if invoked with the 'new' keyword -
called
The function or callable being invoked
-