@@ -10,7 +10,6 @@ public enum JSValue: Equatable {
1010 case null
1111 case undefined
1212 case function( JSFunction )
13- case symbol( JSSymbol )
1413
1514 /// Returns the `Bool` value of this JS value if its type is boolean.
1615 /// If not, returns `nil`.
@@ -68,13 +67,6 @@ public enum JSValue: Equatable {
6867 }
6968 }
7069
71- public var symbol : JSSymbol ? {
72- switch self {
73- case let . symbol( symbol) : return symbol
74- default : return nil
75- }
76- }
77-
7870 /// Returns the `true` if this JS value is null.
7971 /// If not, returns `false`.
8072 public var isNull : Bool {
@@ -88,38 +80,39 @@ public enum JSValue: Equatable {
8880 }
8981}
9082
91- public extension JSValue {
83+ extension JSValue {
9284 /// An unsafe convenience method of `JSObject.subscript(_ name: String) -> ((ConvertibleToJSValue...) -> JSValue)?`
9385 /// - Precondition: `self` must be a JavaScript Object and specified member should be a callable object.
94- subscript( dynamicMember name: String ) -> ( ( ConvertibleToJSValue . . . ) -> JSValue ) {
86+ public subscript( dynamicMember name: String ) -> ( ( ConvertibleToJSValue . . . ) -> JSValue ) {
9587 object![ dynamicMember: name] !
9688 }
9789
9890 /// An unsafe convenience method of `JSObject.subscript(_ index: Int) -> JSValue`
9991 /// - Precondition: `self` must be a JavaScript Object.
100- subscript( dynamicMember name: String ) -> JSValue {
92+ public subscript( dynamicMember name: String ) -> JSValue {
10193 get { self . object![ name] }
10294 set { self . object![ name] = newValue }
10395 }
10496
10597 /// An unsafe convenience method of `JSObject.subscript(_ index: Int) -> JSValue`
10698 /// - Precondition: `self` must be a JavaScript Object.
107- subscript( _ index: Int ) -> JSValue {
99+ public subscript( _ index: Int ) -> JSValue {
108100 get { object![ index] }
109101 set { object![ index] = newValue }
110102 }
111103}
112104
113105extension JSValue : Swift . Error { }
114106
115- public extension JSValue {
116- func fromJSValue< Type> ( ) -> Type ? where Type: ConstructibleFromJSValue {
107+ extension JSValue {
108+ public func fromJSValue< Type> ( ) -> Type ? where Type: ConstructibleFromJSValue {
117109 return Type . construct ( from: self )
118110 }
119111}
120112
121- public extension JSValue {
122- static func string( _ value: String ) -> JSValue {
113+ extension JSValue {
114+
115+ public static func string( _ value: String ) -> JSValue {
123116 . string( JSString ( value) )
124117 }
125118
@@ -148,12 +141,12 @@ public extension JSValue {
148141 /// eventListenter.release()
149142 /// ```
150143 @available ( * , deprecated, message: " Please create JSClosure directly and manage its lifetime manually. " )
151- static func function( _ body: @escaping ( [ JSValue ] ) -> JSValue ) -> JSValue {
144+ public static func function( _ body: @escaping ( [ JSValue ] ) -> JSValue ) -> JSValue {
152145 . object( JSClosure ( body) )
153146 }
154147
155148 @available ( * , deprecated, renamed: " object " , message: " JSClosure is no longer a subclass of JSFunction. Use .object(closure) instead. " )
156- static func function( _ closure: JSClosure ) -> JSValue {
149+ public static func function( _ closure: JSClosure ) -> JSValue {
157150 . object( closure)
158151 }
159152}
@@ -177,7 +170,7 @@ extension JSValue: ExpressibleByFloatLiteral {
177170}
178171
179172extension JSValue : ExpressibleByNilLiteral {
180- public init ( nilLiteral _ : ( ) ) {
173+ public init ( nilLiteral: ( ) ) {
181174 self = . null
182175 }
183176}
@@ -212,28 +205,14 @@ public func setJSValue(this: JSObject, index: Int32, value: JSValue) {
212205 }
213206}
214207
215- public func getJSValue( this: JSObject , symbol: JSSymbol ) -> JSValue {
216- var rawValue = RawJSValue ( )
217- _get_prop ( this. id, symbol. id,
218- & rawValue. kind,
219- & rawValue. payload1, & rawValue. payload2)
220- return rawValue. jsValue
221- }
222-
223- public func setJSValue( this: JSObject , symbol: JSSymbol , value: JSValue ) {
224- value. withRawJSValue { rawValue in
225- _set_prop ( this. id, symbol. id, rawValue. kind, rawValue. payload1, rawValue. payload2)
226- }
227- }
228-
229- public extension JSValue {
230- /// Return `true` if this value is an instance of the passed `constructor` function.
231- /// Returns `false` for everything except objects and functions.
232- /// - Parameter constructor: The constructor function to check.
233- /// - Returns: The result of `instanceof` in the JavaScript environment.
234- func isInstanceOf( _ constructor: JSFunction ) -> Bool {
208+ extension JSValue {
209+ /// Return `true` if this value is an instance of the passed `constructor` function.
210+ /// Returns `false` for everything except objects and functions.
211+ /// - Parameter constructor: The constructor function to check.
212+ /// - Returns: The result of `instanceof` in the JavaScript environment.
213+ public func isInstanceOf( _ constructor: JSFunction ) -> Bool {
235214 switch self {
236- case . boolean, . string, . number, . null, . undefined, . symbol :
215+ case . boolean, . string, . number, . null, . undefined:
237216 return false
238217 case let . object( ref) :
239218 return ref. isInstanceOf ( constructor)
@@ -248,12 +227,11 @@ extension JSValue: CustomStringConvertible {
248227 switch self {
249228 case let . boolean( boolean) :
250229 return boolean. description
251- case let . string( string) :
230+ case . string( let string) :
252231 return string. description
253- case let . number( number) :
232+ case . number( let number) :
254233 return number. description
255- case let . object( object) , let . function( object as JSObject ) ,
256- . symbol( let object as JSObject ) :
234+ case . object( let object) , . function( let object as JSObject ) :
257235 return object. toString!( ) . fromJSValue ( ) !
258236 case . null:
259237 return " null "
0 commit comments