I’m importing a library in a project and I can’t find a method that I’m supposed to use.
The functions name is itDoesntMatterFunctionName()
.
Is there a search by function name in the chrome debugger tools that if I give it an object it will find it?
Example:
var myApp = new ComplexApplication();
console.find(myApp, "myFunctionName");
It’s entirely possible that this function is not exported by the module because note this error:
Uncaught SyntaxError: The requested module './lib/pixi/pixi.mjs' does not provide an export named 'getCanvasBoundingBox'
But it does find other classes / objects in the module.
Chrome debugger / Dev tools Filter box (does not find methods or properties on objects which is what I want):
The Javascript pseudocode for this would be something like:
var object = window.document;
var searchString = "body";
// loop through all objects and property names on the object
while (object typeof object) {
if (object[searchString]!==undefined) {
// return object path
}
// loop through all properties on object recursively
}
2
Answers
in my personal libraries i call this an apiExplorer and it goes something like this, its fairly primitive and could do with going to version 2, any help would be great, for instance it doesnt check for circular references
if the function does actually exists and you want to find where it is or look at etc, you can then do
and step into it for instance
Are you looking to traverse an object recursively looking for a specific key?