-
Notifications
You must be signed in to change notification settings - Fork 0
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
Pre-compute all paths to functions in the provided exposedMethods
object
#2
Comments
To accomplish this we might need the following functions: function isPrimitiveOrBoxed(value) {}
function isCallable(value) {}
function getEntries(value) {}
Once these work they could be assembled something like the following: function* deepEntries(value) {
if (isPrimitiveOrBoxed(value)) {
return;
}
if (isCallable(value)) {
// register path to callable
yield { path: [], callable: value };
}
for (const [k, v] of getNonNativeEntries(value)) {
for (const { path, callable } of deepEntries(v)) {
yield { path: [k, ...path], callable };
}
}
}
Libraries for getting the prototype chain: |
Tests:
|
This is proving to be quite a heavy lift. Instead, it might make sense to keep the logic the same as today, but layer in:
|
Maybe the simplest method is:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
Object.keys()
to navigate all possible paths that point to a function.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
The text was updated successfully, but these errors were encountered: