-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up the JSObjectRef API #28
Conversation
…nce methods" This reverts commit c4d2e12.
Inspired by the public protocol JSValueConvertible {
subscript(jsValue _: ()) -> JSValue { get }
}
extension JSValue {
public init(from convertible: JSValueConvertible) {
self = convertible[jsValue: ()]
}
} |
Alright, the tests are still failing because it seems like I can’t have Any suggestions? |
Update: I’ve replaced all the function call/new logic with this pattern: // idiomatic JS version on next line
foo()
foo()
foo(arg1, arg2, arg3)
foo(arg1, arg2, arg3)
foo(args: [arg1, arg2, arg3])
foo(...[arg1, arg2, arg3])
foo(this: bar)
foo.call(bar)
foo(this: bar, arg1, arg2, arg3)
foo.call(bar, arg1, arg2, arg3)
foo(this: bar, args: [arg1, arg2, arg3])
foo.apply(bar, [arg1, arg2, arg3])
foo(new: arg1, arg2, arg3)
new foo(arg1, arg2, arg3)
foo(.new, args: [arg1, arg2, arg3])
new foo(...[arg1, arg2, arg3])
foo(.new)
new foo() The last two I’m a little uncertain of. |
One last change I was going to make was changing the It seems Swift doesn’t allow letters in operators, so |
Sorry, I didn't take a look much now, but could you ignore .swiftpm directory? |
Sorry for late response. I basically agree with deprecating get and set and provide subscript. But on second thought, This library provides JavaScript like APIs but also they should be swifty. I think I disagree that APIs become unnatural caring about edge cases. |
Good point! I reverted those changes, so now the last few samples look like this: foo.new(arg1, arg2, arg3)
new foo(arg1, arg2, arg3)
foo.new(args: [arg1, arg2, arg3])
new foo(...[arg1, arg2, arg3])
foo.new()
new foo() Additionally, I changed the JSValue code back to using Ah, did a quick GitHub search and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that isInstanceOf
member name is used by only some testing frameworks, so I think it's ok to keep isInstanceOf
.
Fixes #27.
get
/set
→dynamicMember
and subscriptsinstanceof
(kept)jsValue
(kept)apply
→callAsFunction