Skip to content

Commit db421db

Browse files
committed
Last change to functions, hopefully
1 parent 3a4ccee commit db421db

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Sources/JavaScriptKit/JSFunction.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ public class JSFunctionRef: JSObjectRef {
3333
self(this: this, args: args)
3434
}
3535

36-
public func callAsFunction(new arguments: JSValueConvertible...) -> JSObjectRef {
37-
arguments.withRawJSValues { rawValues in
36+
public func callAsFunction(new args: JSValueConvertible...) -> JSObjectRef {
37+
self(.new, args: args)
38+
}
39+
40+
public func callAsFunction(_: _JSFunctionConstructorSymbol, args: [JSValueConvertible] = []) -> JSObjectRef {
41+
args.withRawJSValues { rawValues in
3842
rawValues.withUnsafeBufferPointer { bufferPointer in
3943
let argv = bufferPointer.baseAddress
4044
let argc = bufferPointer.count
@@ -47,11 +51,6 @@ public class JSFunctionRef: JSObjectRef {
4751
}
4852
}
4953
}
50-
public func callAsFunction(_: _JSFunctionConstructorSymbol) -> JSObjectRef {
51-
var resultObj = JavaScriptObjectRef()
52-
_call_new(self.id, nil, 0, &resultObj)
53-
return JSObjectRef(id: resultObj)
54-
}
5554

5655
@available(*, unavailable, message: "Please use JSClosure instead")
5756
public static func from(_: @escaping ([JSValue]) -> JSValue) -> JSFunctionRef {

0 commit comments

Comments
 (0)