     var jsIdentifier: Double {
         return Double(UInt64(objectId) & ((1 << 53) - 1))
     }
-    var asJSObject: Any {
+    var asJSObject: [AnyHashable: Any] {
         return [
             "id": jsIdentifier,
             "uuid": uuid.fullUUIDString,

}

extension Peripheral {
    func asJSObject(withRssi: Int? = nil) -> Any {
        return [
            "id": identifier.uuidString,
            "name": name as Any,

import CoreBluetooth

extension RestoredState {
    var asJSObject: [AnyHashable: Any] {
        return [
            "connectedPeripherals": peripherals.map { $0.asJSObject } as [Any]
        ]
    }
}

extension ScannedPeripheral {
    var asJSObject: [AnyHashable: Any] {
        var serviceData: [String:String]?
        if let advServiceData = advertisementData.serviceData {
            var data = [String:String]()
