|
1 | 1 | import _CJavaScriptKit
|
2 | 2 |
|
3 | 3 | public final class JSDictionary {
|
4 |
| - private let ref: JSObject |
| 4 | + private let ref: JSObject |
5 | 5 |
|
6 |
| - init(ref: JSObject) { self.ref = ref } |
| 6 | + init(ref: JSObject) { self.ref = ref } |
7 | 7 |
|
8 |
| - public init() { ref = JSObject(id: swjs_create_object()) } |
| 8 | + public init() { ref = JSObject(id: swjs_create_object()) } |
9 | 9 |
|
10 |
| - public subscript(key: String) -> JSValue { |
11 |
| - get { ref[dynamicMember: key] } |
12 |
| - set { ref[dynamicMember: key] = newValue } |
13 |
| - } |
| 10 | + public subscript(key: String) -> JSValue { |
| 11 | + get { ref[dynamicMember: key] } |
| 12 | + set { ref[dynamicMember: key] = newValue } |
| 13 | + } |
14 | 14 | }
|
15 | 15 |
|
16 | 16 | extension JSDictionary: ExpressibleByDictionaryLiteral {
|
17 |
| - public convenience init(dictionaryLiteral elements: (String, JSValue)...) { |
18 |
| - self.init() |
| 17 | + public convenience init(dictionaryLiteral elements: (String, JSValue)...) { |
| 18 | + self.init() |
19 | 19 |
|
20 |
| - for (key, value) in elements { self[key] = value } |
21 |
| - } |
| 20 | + for (key, value) in elements { self[key] = value } |
| 21 | + } |
22 | 22 | }
|
23 | 23 |
|
24 | 24 | extension JSDictionary: ConvertibleToJSValue {
|
25 |
| - public var jsValue: JSValue { .object(ref) } |
| 25 | + public var jsValue: JSValue { .object(ref) } |
26 | 26 | }
|
27 | 27 |
|
28 | 28 | extension JSDictionary: ConstructibleFromJSValue {
|
29 |
| - public static func construct(from value: JSValue) -> JSDictionary? { |
30 |
| - guard let object = value.object else { return nil } |
| 29 | + public static func construct(from value: JSValue) -> JSDictionary? { |
| 30 | + guard let object = value.object else { return nil } |
31 | 31 |
|
32 |
| - return JSDictionary(ref: object) |
33 |
| - } |
| 32 | + return JSDictionary(ref: object) |
| 33 | + } |
34 | 34 | }
|
0 commit comments