Skip to content

Commit 8f05e88

Browse files
committed
Fixed JSEncoder
1 parent 9fbb5e7 commit 8f05e88

File tree

4 files changed

+170
-112
lines changed

4 files changed

+170
-112
lines changed

Example/JavaScriptKitExample/Sources/JavaScriptKitExample/main.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ JSConsole.log(date.description)
1616
if let bluetooth = JSBluetooth.shared {
1717
bluetooth.isAvailable.then {
1818
JSConsole.assert($0, "Bluetooth not available")
19+
}.catch { (error: JSError) in
20+
JSConsole.debug(#file, #function, #line)
21+
JSConsole.error(error)
1922
}
2023
let buttonElement = document.createElement!("button").object!
2124
buttonElement.innerText = "Scan for Bluetooth devices"

Sources/JavaScriptKit/JS Types/JSArray.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ public final class JSArray: JSType {
1818
assert(Self.isArray(jsObject))
1919
}
2020

21-
public convenience init<C>(_ collection: C) where C: Collection, C.Element == JSValue {
22-
self.init(count: collection.count)
23-
collection.enumerated().forEach { self[$0.offset] = $0.element }
24-
}
25-
2621
public convenience init<C>(_ collection: C) where C: Collection, C.Element == JSValueConvertible {
2722
self.init(collection.map({ $0.jsValue() }))
2823
}
@@ -33,7 +28,8 @@ internal extension JSArray {
3328
static let classObject = JSObjectRef.global.Array.function!
3429

3530
static func isArray(_ object: JSObjectRef) -> Bool {
36-
classObject.isArray.function?(object).boolean ?? false
31+
let function = classObject.isArray.function.assert()
32+
return function(object).boolean.assert()
3733
}
3834
}
3935

0 commit comments

Comments
 (0)