title: How to test file permissions using node.js?
body: <p>How can I check to see the permissions (read/write/execute) that a running node.js process has on a given file?</p>
  
  <p>I was hoping that the <a href="http://nodejs.org/docs/latest/api/fs.html#fs_class_fs_stats" rel="noreferrer"><code>fs.Stats</code> object</a> had some information about permissions but I don't see any.  Is there some built-in function that will allow me to do such checks?  For example:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>var filename = '/path/to/some/file';
  if (fs.canRead(filename)) // OK...
  if (fs.canWrite(filename)) // OK...
  if (fs.canExecute(filename)) // OK...
  </code></pre>
  
  <p>Surely I don't have to attempt to open the file in each of those modes and handle an error as the negative affirmation, right?  There's got to be a simpler way...</p>