The value of `i` will never be greater than `fullPath.length`, so that test can be omitted.

I don't think the behavior is correct when i == -1. If you just have "foo", what is the directory path? I think it's better to return "" then "foo". 

In other words, I think this whole function can be simplified to:

```
function getDirectoryPath(fullPath) {
    return fullPath.substr(0, fullPath.lastIndexOf("/") + 1);
}
```

And the JSDoc description should be updated to reflect the actual behavior of returning the parent directory if a file is passed, or the directory itself if a directory is passed.