JavaScriptKit
JavaScriptKit copied to clipboard
Do we need new enum cases in `JSValue` for closures?
Now that JSClosure and JSOneshotClosure are no longer subclasses of JSFunction, how are they supposed to be converted to JSValue? Should the object case be used?
I think the object case should be used for this purpose because we don't need to distinguish object case and closure case internally. If you want API consistency, we can add a new static func instead of a new case.
static func closure(_ closure: JSClosure) -> JSValue { .object(closure) }
Yeah, that would make sense, I can see people being confused when there is JSValue.function, but no JSValue.closure