-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Implement using Proxy #73
Conversation
Thanks for working on this 🙌
Would be nice to just handle this though. Imagine using See sindresorhus/on-change#16 for how it was handled on another package of mine.
Doesn't the "own" word imply it doesn't apply when inherited? |
test.js
Outdated
const obj = {[sym]: cb => setImmediate(cb)}; | ||
const pified = m(obj); | ||
await pified[sym](); | ||
t.pass(); |
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.
Use t.notThrows
instead.
I think this also fixes: Can you add some more tests? |
Seems so! I totally missed that. |
I think #63 was fixed in #69. However, it's good that you brough it up because this PR breaks To fix this I can add an additional condition that we will not promisify a property if its value is taken from #48 is fixed-ish. The problem is that a method called through the pify proxy will receive as |
👍
👍 |
@sindresorhus Can you please clarify what tests you’d like me to add? |
I've tackled the remaining issues mentioned, and added tests for those things. I feel that the existing test suite is quite comprehensive. If you have concrete tests you would like me to add let me know though. |
Looks good now. Great work 👌 |
Fixes #29. Fixes #57.
This implementation changes the behavior when the wrapped object is mutated. It will act as a promisified "view" of the underlying object, rather than a promisified clone. Thus, if properties (including methods) change in the underlying object, the promisified view will also be updated. This change is reflected in a change in one of the existing tests.
I also fixed a bug where symbol properties were incorrectly handled, although that's unrelated to using Proxy.
Regarding this issue in #32:
As far as I could tell, addressing this is complicated because you need to get the property descriptor which may be inherited, and there is no native API to do that so you have manually walk the prototype chain.
Where should we document the caveat that pify will not work in this case?
IssueHunt Summary
Referenced issues
This pull request has been submitted to:
IssueHunt has been backed by the following sponsors. Become a sponsor