Skip to content

Commit 8b181c7

Browse files
committed
Clean up AnyJSValueConvertible
1 parent b62b78e commit 8b181c7

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

Sources/JavaScriptKit/Support.swift

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
protocol _AnyJSValueCodable: JSValueConvertible {}
1+
protocol _AnyJSValueConvertible: JSValueConvertible {}
22

3-
public struct AnyJSValueCodable: JSValueCodable, ExpressibleByNilLiteral {
4-
public static let void = AnyJSValueCodable.construct(from: .undefined)
3+
public struct AnyJSValueConvertible: JSValueCodable, ExpressibleByNilLiteral {
4+
public static let void = AnyJSValueConvertible.construct(from: .undefined)
55

6-
private struct Box<T: JSValueConvertible>: _AnyJSValueCodable {
6+
private struct Box<T: JSValueConvertible>: _AnyJSValueConvertible {
77
let value: T
88

99
func jsValue() -> JSValue {
1010
value.jsValue()
1111
}
1212
}
1313

14-
private struct ConcreteBox: _AnyJSValueCodable {
14+
private struct ConcreteBox: _AnyJSValueConvertible {
1515
let value: JSValue
1616

1717
func jsValue() -> JSValue {
1818
return value
1919
}
2020
}
2121

22-
private let value: _AnyJSValueCodable
22+
private let value: _AnyJSValueConvertible
2323

2424
public init<T>(_ value: T) where T: JSValueConvertible {
2525
self.value = Box(value: value)
2626
}
27-
private init(boxed value: _AnyJSValueCodable) {
27+
private init(boxed value: _AnyJSValueConvertible) {
2828
self.value = value
2929
}
3030

31-
public static func construct(from value: JSValue) -> AnyJSValueCodable? {
31+
public static func construct(from value: JSValue) -> AnyJSValueConvertible? {
3232
self.init(boxed: ConcreteBox(value: value))
3333
}
3434

@@ -39,19 +39,4 @@ public struct AnyJSValueCodable: JSValueCodable, ExpressibleByNilLiteral {
3939
public func jsValue() -> JSValue {
4040
value.jsValue()
4141
}
42-
43-
public func fromJSValue<Type: JSValueConstructible>() -> Type? {
44-
self.jsValue().fromJSValue()
45-
}
46-
}
47-
48-
public func staticCast<Type: JSBridgedType>(_ ref: JSBridgedType) -> Type? {
49-
return Type(from: ref.value)
50-
}
51-
52-
public func dynamicCast<Type: JSBridgedClass>(_ ref: JSBridgedClass) -> Type? {
53-
guard ref.jsObject.isInstanceOf(Type.constructor) else {
54-
return nil
55-
}
56-
return staticCast(ref)
5742
}

0 commit comments

Comments
 (0)