atom/node-pathwatcher — pull request #15 by smashwilson (2014-04-22 16:11:54+00:00)
Title: isFile and isDirectory predicates

Until recently, I've been writing directory traversal code in Atom packages as:

```coffeescript
{File, Directory} = require 'pathwatcher'

traverse = (root, callback) ->
root.getEntries (err, list) ->
if err?
callback(err, null)
return

for entry in list
if entry instanceof File
callback(null, entry)
else if entry instanceof Directory
traverse(entry, callback)

traverse atom.project.getRootDirectory(), (file) ->
console.log "File: #{file.getRealPathSync()}"
```

However, when Atom upgrades its internally bundled version of pathwatcher, both "instanceof" checks fail, because the `File` and `Directory` constructors that I'm using for comparison are different than the ones that were used within `getRootDirectory()`.

I've added `isFile()` and `isDirectory()` methods to `File` and `Directory` to provide a more stable way of distinguishing between them in the results of a `getEntries` call.

As a sidenote, how amenable would you be to me adding additional utilities for traversal within `Directory`? I know this isn't an all-purpose node filesystem package, but since Atom returns `Directories` and `Files` in several places in its API, I keep thinking it'd be useful to have them there.