class JSCFunction
- JSCFunction
- Reference
- Object
Overview
JSCFunction represents a JavaScript's native function(a function that run native code instead of javascript).
Included Modules
Defined in:
components/jsc_function.crConstant Summary
-
FUNCTIONS =
[] of JSCFunction
Constructors
-
.new(func : Array(JSCPrimative | JSCFunction | JSCObject) -> _, name : String? = nil, auto_save : Bool = true)
Initializes a JavaScript native function.
Class Method Summary
-
.raise(message : String)
Raises a JavaScript Error with given
message
.
Instance Method Summary
-
#call(*args)
Calls the function.
- #finalize
Instance methods inherited from module Invokable
invoke(name : String, *args)
invoke
Instance methods inherited from module JSObjectUtils
[](name : String)[](index : UInt32) [], []=(name : String, value)
[]=(index : UInt32, value) []=, delete(name : String) delete, is_array? is_array?, is_bool? is_bool?, is_instance_of?(class_name : String) is_instance_of?, is_null? is_null?, is_number? is_number?, is_string? is_string?, is_undefined? is_undefined?, to_b to_b, to_f64 to_f64, to_i32 to_i32, to_s to_s
Constructor Detail
def self.new(func : Array(JSCPrimative | JSCFunction | JSCObject) -> _, name : String? = nil, auto_save : Bool = true)
#
Initializes a JavaScript native function.
For short, uses WebExtension.function
macro instead.
NOTE IMPORTANT. Does not directly use parameter as return value. The following code won't work.
WebExtension.function params do
params.first # => Directly returns function parameter(s) is not recommended and may crash program
end
Class Method Detail
Instance Method Detail
def call(*args)
#
Calls the function.
E.g:
sum_function.call JSCPrimative.new(1), 2
NOTE Calling function this way won't make JS this
operator usable. In case of
invoking object's method, uses Invokable#invoke
instead.