forked from swiftwasm/JavaScriptKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticFunctions.swift
More file actions
56 lines (44 loc) · 1020 Bytes
/
StaticFunctions.swift
File metadata and controls
56 lines (44 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@JS class MathUtils {
@JS init() {}
@JS class func subtract(a: Int, b: Int) -> Int {
return a - b
}
@JS static func add(a: Int, b: Int) -> Int {
return a + b
}
@JS func multiply(x: Int, y: Int) -> Int {
return x * y
}
}
@JS enum Calculator {
case scientific
case basic
@JS static func square(value: Int) -> Int {
return value * value
}
}
@JS
enum APIResult {
case success(String)
case failure(Int)
@JS static func roundtrip(value: APIResult) -> APIResult {}
}
@JS enum Utils {
@JS enum String {
@JS static func uppercase(_ text: String) -> String {
return text.uppercased()
}
}
}
extension MathUtils {
@JS static func divide(a: Int, b: Int) -> Int {
return a / b
}
@JS static var pi: Double { 3.14159 }
}
extension Calculator {
@JS static func cube(value: Int) -> Int {
return value * value * value
}
@JS static var version: String { "1.0" }
}