# find

> Find files or directories by name

Latest version **0.3.0** (published 2019-03-07) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2019-03-07 |
| First published | 2013-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/find) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 47 |
| Author | yuanchuan |
| Maintainers | yuanchuan |
| Keywords | find, findfile, search, files |

## Links

- npm: https://www.npmjs.com/package/find
- Repository: https://github.com/yuanchuan/find
- Homepage: https://github.com/yuanchuan/find#readme
- Issues: https://github.com/yuanchuan/find/issues
- npm.io page: https://npm.io/package/find

## Dependencies (1)

- [traverse-chain](https://npm.io/package/traverse-chain.md) ~0.1.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.3.0 (latest) — 2019-03-07
- 0.2.9 — 2018-01-27
- 0.2.8 — 2018-01-04
- 0.2.7 — 2016-07-14
- 0.2.6 — 2016-06-02
- 0.2.5 — 2016-06-01
- 0.2.4 — 2016-01-03
- 0.2.3 — 2015-07-16
- 0.2.2 — 2015-05-05
- 0.2.1 — 2015-05-01
- 0.2.0 — 2015-05-01
- 0.1.7 — 2014-08-21
- 0.1.6 — 2014-08-21
- 0.1.5 — 2013-12-14
- 0.1.4 — 2013-05-22
- … 4 more at https://npm.io/package/find/versions

## README

# find [![Status](https://travis-ci.org/yuanchuan/find.svg?branch=master)](https://travis-ci.org/yuanchuan/find "See test builds")

Find files or directories by name.

[![NPM](https://nodei.co/npm/find.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/find/)

## Installation

```bash
$ npm install --save find
```

## Examples

Find all files in current directory.

```javascript
var find = require('find');

find.file(__dirname, function(files) {
  console.log(files.length);
})
```

Filter by regular expression.

```javascript
find.file(/\.js$/, __dirname, function(files) {
  console.log(files.length);
})
```

## Features
  * Recursively search each sub-directories
  * Asynchronously or synchronously
  * Filtering by regular expression or string comparing

## Changelog
#### 0.3.0
  * Added `.use()` method

#### 0.2.0
  * The first `pattern` option is now optional
  * Will follow symbolic links


## API

#### .file([pattern,] root, callback)

```javascript
find.file(__dirname, function(files) {
  //
})
```

#### .dir([pattern,] root, callback)
```javascript
find.dir(__dirname, function(dirs) {
  //
})
```


#### .eachfile([pattern,] root, action)

```javascript
find.eachfile(__dirname, function(file) {
  //
})
```

#### .eachdir([pattern,] root, action)

```javascript
find.eachdir(__dirname, function(dir) {
  //
})
```

#### .fileSync([pattern,] root)
```javascript
var files = find.fileSync(__dirname);
```

#### .dirSync([pattern,] root)
```javascript
var dirs = find.dirSync(__dirname);
```

#### .error([callback])

Handling errors in asynchronous interfaces

```javascript
find
  .file(__dirname, function(file) {
    //
  })
  .error(function(err) {
    if (err) {
      //
    }
  })
```

#### .end([callback])

Detect `end` in `find.eachfile` and `find.eachdir`

```javascript
find
  .eachfile(__dirname, function(file) {
    //
  })
  .end(function() {
    console.log('find end');
  })
```

#### .use(Options)
  * `fs`: The internal fs object to be used.

```javascript
const { fs, vol } = require('memfs');

const json = {
  './README.md': '1',
  './src/index.js': '2'
};

vol.fromJSON(json, '/app');

find
  .use({ fs: fs })
  .file('/app', console.log);
```

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