# dir-to-object

> Builds an object from the files contained inside a directory.

Latest version **2.0.0** (published 2018-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install dir-to-object
pnpm add dir-to-object
yarn add dir-to-object
bun add dir-to-object
```

## 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.0 |
| Published | 2018-10-19 |
| First published | 2018-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mattia Richetto |
| Maintainers | mattiaerre |
| Keywords | dir, directory, files, object |

## Links

- npm: https://www.npmjs.com/package/dir-to-object
- Repository: https://github.com/mattiaerre/dir-to-object
- Homepage: https://github.com/mattiaerre/dir-to-object#readme
- Issues: https://github.com/mattiaerre/dir-to-object/issues
- npm.io page: https://npm.io/package/dir-to-object

## 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

- 2.0.0 (latest) — 2018-10-19
- 1.0.0 — 2018-09-01
- 1.0.0-beta.1 — 2018-08-30
- 1.0.0-alpha.4 — 2018-08-30
- 1.0.0-alpha.3 — 2018-08-30
- 1.0.0-alpha.2 — 2018-08-29
- 1.0.0-alpha.1 — 2018-08-29

## README

# dir-to-object

> Builds an object from the files contained inside a directory.

## Installation

```bash
npm install dir-to-object
```

## Usage example

```bash
const dirToObject = require('dir-to-object');
const { join } = require('path');

const path = join(__dirname, './__mocks__/foo');

const options = { canAdd: () => true };

const bar = dirToObject(path, options);

console.log(bar);
```

Where **path** is a string and it is required:

> e.g.: `join(__dirname, './foo')`

And where **config** is an object with the following property:

| name   | type                          | example                             | required or optional |
| ------ | ----------------------------- | ----------------------------------- | -------------------- |
| canAdd | _function_: (data) => boolean | `data => data.resolve && data.type` | _optional_           |

## Contributing

1. [Fork it](https://github.com/mattiaerre/dir-to-object/fork)
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request

## License

Distributed under the MIT license. See [LICENSE](LICENSE) for more information.

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