Obtaining a list of available functions for a Class in Node.js
<p>I am trying to find a clean, easy way to simply get the list of available functions for a class in Node.js using the command line.</p>

<p>Based on previous web searches I've stumbled upon <code>Object.getOwnPropertyNames()</code> but it appears that this function is inconsistent, or else I don't understand why it works for some classes but not others.</p>

<p>Let's work through an example and maybe someone can help. Currently, node -v outputs v4.4.5 for this example.</p>

<p>First, suppose I wanted to get a list of the functions for the Math class. From the node console, this works great, I get:</p>

<pre><code>[root@localhost /]# node
&gt; Object.getOwnPropertyNames(Math)
[ 'E',
  'LN10',
  'LN2',
  'LOG2E',
  'LOG10E',
  'PI',
  'SQRT1_2',
  'SQRT2',
  'random',
  'abs',
  'acos',
  'asin',
  'atan',
  'ceil',
  'exp',
  'floor',
  'log',
  'round',
  'sqrt',
  'atan2',
  'pow',
  'max',
  'min',
  'imul',
  'sign',
  'trunc',
  'tanh',
  'asinh',
  'acosh',
  'atanh',
  'hypot',
  'fround',
  'clz32',
  'cbrt',
  'cos',
  'sin',
  'tan',
  'sinh',
  'cosh',
  'log10',
  'log2',
  'log1p',
  'expm1' ]
&gt;
</code></pre>

<p>Cool. That works.</p>

<p>Now, since Node.js is more about server side programming, let's see if the same thing works for a common class that is used in nearly every single "hello world" type of example for Node.js: <code>http.Server</code></p>

<p>Let's try the same thing:</p>

<pre><code>&gt; Object.getOwnPropertyNames(http.Server)
[ 'length', 'name', 'prototype', 'super_' ]
</code></pre>

<p>Hmmm.... comparing this to the documentation <a href="https://nodejs.org/api/http.html#http_class_http_server" rel="noreferrer">here</a>, it seems that it's missing basic things like <code>server.close()</code>, <code>server.listen()</code>. Looking at the docs further, this class is a subclass of <code>net.Server</code>, so maybe I have to look at the methods for that class instead. Let's see if that works:</p>

<pre><code>&gt; Object.getOwnPropertyNames(net.Server)
[ 'length', 'name', 'prototype', 'super_' ]
</code></pre>

<p>Hmmm... If we compare to the documentation for <a href="https://nodejs.org/api/net.html#net_class_net_server" rel="noreferrer">net.Server</a> we're missing basic functions like <code>server.address()</code>, <code>server.getConnections()</code> and others. </p>

<p>Can anyone help me understand:</p>

<p>(a) Why <code>getOwnPropertyNames</code> seems to show all the methods for some classes but not others, and...
(b) Is there another 'official' way to simply list the available functions for an object in Node.js without having to read the API docs to get such a list?</p>