# objectify-fs

> Creates a detailed directory JS object structure.

Latest version **1.1.1** (published 2019-05-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install objectify-fs
pnpm add objectify-fs
yarn add objectify-fs
bun add objectify-fs
```

## 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 | 1.1.1 |
| Published | 2019-05-22 |
| First published | 2019-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matt Bolitho |
| Maintainers | mattbolitho |
| Keywords | objectify, js, object, file, system, directory, file |

## Links

- npm: https://www.npmjs.com/package/objectify-fs
- Repository: https://github.com/MattBolitho/objectify-fs
- Homepage: https://github.com/MattBolitho/objectify-fs#readme
- Issues: https://github.com/MattBolitho/objectify-fs/issues
- npm.io page: https://npm.io/package/objectify-fs

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.1 (latest) — 2019-05-22
- 1.1.0 — 2019-05-17
- 1.0.0 — 2019-05-14
- 0.0.1 — 2019-05-14

## README

# objectify-fs
objectify-fs is a node module that creates a JS object containing information about a directory and its children from an input root.

The return value is an array containin objects representing directories and files.

Directories objects contain their name, relative path and directory contents in an array.

File objects contain information about the name, relative path, size in bytes and the file contents.

**Example file structure**
```js
{ 
    name: 'LICENSE',
    file: true,
    path: 'LICENSE',
    content: <Buffer 4d 49 54 20 4c 69... >,
    size: 1078 
}
```

**Example directory structure**
```js
{ 
    name: '.git',
    dir: true,
    path: '.git',
    contents: [ 
        /* Array of objects in directory */ 
    ]
}
```


### Objectify Synchronously
The objectifySync function returns an object containing data about the input directory synchronously.

The inputs are the the path to the directory as a string and an object containing options. This options object can contain an array of file extensions as strings, or an array of RegExps to match file names against. 

**Usage examples**
```js
const objectifyFs = require("objectify-fs");

const directoryData = objectifyFs.objectifySync("path/to/directory");

const cFiles = objectifyFs.objectifySync("path/to/directory", {
    extensions:[".c"]
});

const numberNames = objectifyFs.objectifySync("path/to/directory", {
    patterns:[new RegExp("^[0-9]+$")]
});
```

### Objectify Asynchronously
The objectifySync function returns a promise. If no error occurs, the promise is resolved with the object representing input directory.

The inputs are the the path to the directory as a string. The options are currently not supported in the async objectify function in this version.

**Usage example**
```js
const objectifyFs = require("objectify-fs");

const directoryData = objectifyFs.objectify("path/to/directory").then(console.log);
```

### To do
The module needs:
- Tests
- RegExp/Extension matching on async version.

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