Class
JSThrowingFunction
public class JSThrowingFunction
A JSFunction
wrapper that enables throwing function calls.
Exceptions produced by JavaScript functions will be thrown as JSValue
.
Initializers
init(_:)
public init(_ base: JSFunction)
Methods
callAsFunction(this:arguments:)
@discardableResult
public func callAsFunction(this: JSObject? = nil, arguments: [ConvertibleToJSValue]) throws -> JSValue
Call this function with given arguments
and binding given this
as context.
Parameters
Name | Type | Description |
---|---|---|
this | JSObject? |
The value to be passed as the |
arguments | [ConvertibleToJSValue] |
Arguments to be passed to this function. |
Returns
The result of this call.
callAsFunction(this:_:)
@discardableResult
public func callAsFunction(this: JSObject? = nil, _ arguments: ConvertibleToJSValue...) throws -> JSValue
A variadic arguments version of callAsFunction
.
new(arguments:)
public func new(arguments: [ConvertibleToJSValue]) throws -> JSObject
Instantiate an object from this function as a throwing constructor.
Guaranteed to return an object because either:
-
a. the constructor explicitly returns an object, or
-
b. the constructor returns nothing, which causes JS to return the
this
value, or -
c. the constructor returns undefined, null or a non-object, in which case JS also returns
this
.
Parameters
Name | Type | Description |
---|---|---|
arguments | [ConvertibleToJSValue] |
Arguments to be passed to this constructor function. |
Returns
A new instance of this constructor.
new(_:)
public func new(_ arguments: ConvertibleToJSValue...) throws -> JSObject
A variadic arguments version of new
.