Reputation: 78890
I'm writing some code that will do some introspection on a Function
in node. Specifically, I want to hopefully do non-standard-JS things like listing source code line numbers. However, there appears to be no reference documentation available on global types in node/v8 to see what's available.
The Global Objects documentation for node doesn't have this information. Although MDN documents Function, it only lists standard methods/properties or its own non-standard extensions. Also, its compatibility chart focuses on browser JS engines. It helped me find the name
property of a function at least.
The REPL isn't helping me either:
> function foo() { }
undefined
> foo
[Function: foo]
> console.dir(foo)
[Function: foo]
undefined
> Object.keys(foo)
[]
> Object.keys(Function.prototype)
[]
>
Is there any sort of reference documentation for global node types?
Upvotes: 1
Views: 144
Reputation: 76
function allProps(obj, name = '') {
if (obj == null) return; // recursion to the final link in this prototype chain
console.log(name, Object.getOwnPropertyNames(obj));
allProps(Object.getPrototypeOf(obj), 'prototype');
}
allProps(Function, 'Function');
allProps(Function.prototype, 'Function.prototype');
allProps(Function.__proto__, 'Function.__proto__');
Upvotes: 1