# isdir

> check if a descriptor is a directory.

Latest version **2.0.1** (published 2015-08-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install isdir
pnpm add isdir
yarn add isdir
bun add isdir
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2015-08-31 |
| First published | 2015-03-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | @nelsonic |
| Maintainers | nelsonic |
| Keywords | is, directory, check |

## Links

- npm: https://www.npmjs.com/package/isdir
- Repository: https://github.com/dwyl/isdir
- Issues: https://github.com/dwyl/isdir/issues
- npm.io page: https://npm.io/package/isdir

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2015-08-31
- 2.0.0 — 2015-03-22
- 1.2.0 — 2015-03-22
- 1.0.1 — 2015-03-22
- 1.0.0 — 2015-03-21

## README

# isdir

[![Build Status](https://travis-ci.org/dwyl/isdir.svg)](https://travis-ci.org/dwyl/isdir)
[![Test Coverage](https://codeclimate.com/github/dwyl/isdir/badges/coverage.svg)](https://codeclimate.com/github/dwyl/isdir)
[![Code Climate](https://codeclimate.com/github/dwyl/isdir/badges/gpa.svg)](https://codeclimate.com/github/dwyl/isdir)
[![Node.js Version][node-version-image]][node-version-url] [![NPM Version][npm-image]][npm-url]
[![Dependency Status](https://david-dm.org/dwyl/esta.svg)](https://david-dm.org/dwyl/esta)

`isdir` checks if a given file descriptor `fd` is a directory or not.  
(wrapper around node's native `fs.stat.isDirectory()` method )

## Usage

### Install from NPM

```sh
npm install isdir --save
```

### In your script

```js
var isdir = require('isdir');
var fd    = __dirname; // or what ever you need to check

isdir(fd, function callback(err, dir) { // named callback function
  if(err) { // you will get an error back if fd was not a readable file or dir
    console.log("Oopsy: " + err); // handle errors in your preferred way.
  }
  else if(dir) {
    console.log(fd + " is a directory!"); // do something with the directory
  }
  else {
    console.log(fd + " is NOT a directory!") // its a file
  }
});
```


## About

We needed a ***fully tested*** *simple* call to check if a descriptor
is a directory for our [***faster***](https://github.com/ideaq/faster) project.

This module *deliberately* only exposes a single ***asynchronous*** method.

If you prefer to use it *sychronously*
(go for a walk and consider switching programming languages)
and if you still want to use it sync just assign the output to varaiable
and omit the callback:

```js
var isdir = require('isdir');
var fd    = __dirname;        // or what ever descriptor you need to check
var dir   = isdir(__dirname); // this works but is not encouraged (its blocking)
if(dir) {
  // do what you want with your directory
}
```

Influenced by: https://github.com/jonschlinkert/is-directory
(We wanted lighter error-handling and more tests)


[npm-image]: https://img.shields.io/npm/v/isdir.svg?style=flat
[npm-url]: https://npmjs.org/package/isdir
[node-version-image]: https://img.shields.io/node/v/isdir.svg?style=flat
[node-version-url]: http://nodejs.org/download/
[downloads-image]: https://img.shields.io/npm/dm/isdir.svg?style=flat
[downloads-url]: https://npmjs.org/package/isdir
[travis-image]: https://img.shields.io/travis/dwyl/isdir.svg?style=flat
[travis-url]: https://travis-ci.org/dwyl/isdir
[dependencies-url]: https://david-dm.org/dwyl/isdir
[dependencies-image]: https://david-dm.org/dwyl/isdir.svg

---
_Source: https://npm.io/package/isdir · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
