-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Mark array() method as deprecated with warning message #8187
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
base: dev-2.0
Are you sure you want to change the base?
Conversation
src/math/p5.Vector.js
Outdated
| * </div> | ||
| */ | ||
| array() { | ||
| p5._friendlyError( |
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.
This is currently throwing errors in the tests. Inside of classes, we don't have access to a global p5. We do have access to them in the exported addon function body though. In #8176 I dealt with something similar by patching the class in the exported addon function to give it access to these.
Also, once this does work, we probably don't want to flood the user's console with logs if they're using this a bunch every frame. We should maybe track whether or not we've logged this warning yet, and don't log it a second time.
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.
Thanks for your help sharing this pattern made the fix super easy
a333725 to
4201812
Compare
|
As long as this is being changed, I suggest updating the documentation as well. Change from "Returns the vector's components as an array of numbers" to something like "Returns the vector's first three components as an array of three numbers." The existing example is great; it makes clear that the result will have three numbers even for a 2D array. I also suggest including a pointer to its replacement in the deprecation message (and perhaps something similar in the FES message):
|
Resolves #8151
Changes:
Marked both the static and instance version of the array() method as deprecated
PR Checklist
npm run lintpasses