# isotropy-ast-analyzer-fs

> Isotropy AST Analyzer for FS ============================ This module abstracts AST analysis for common filesystem operations so that they don't have to be repeated in every filesystem plugin. This is part of the isotropy framework (www.isotropy.org).

Latest version **0.0.5** (published 2017-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install isotropy-ast-analyzer-fs
pnpm add isotropy-ast-analyzer-fs
yarn add isotropy-ast-analyzer-fs
bun add isotropy-ast-analyzer-fs
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2017-09-23 |
| First published | 2017-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Arivanandan |
| Maintainers | jeswin, arivanandan |

## Links

- npm: https://www.npmjs.com/package/isotropy-ast-analyzer-fs
- npm.io page: https://npm.io/package/isotropy-ast-analyzer-fs

## Dependencies (3)

- [ramda](https://npm.io/package/ramda.md) ^0.23.0
- [lazily](https://npm.io/package/lazily.md) ^0.0.17
- [chimpanzee](https://npm.io/package/chimpanzee.md) 0.0.50

## Recent versions

- 0.0.5 (latest) — 2017-09-23
- 0.0.4 — 2017-09-23
- 0.0.3 — 2017-09-23
- 0.0.1 — 2017-08-17

## README

Isotropy AST Analyzer for FS
============================
This module abstracts AST analysis for common filesystem operations so that they don't have to be repeated in every filesystem plugin.
This is part of the isotropy framework (www.isotropy.org).

Create a module "fs.js" containing an array that mocks the filesystem.
The filename can be changed in configuration.
```javascript
//In fs.js
export default [
  {
    { dir: "pictures", filename: "stock_photo1.jpg", contents: "FF D8 FF ..." },
    { dir: "trash", filename: "not-passwords.txt", contents: "thisisnotpassword" }
  }
]
```

Create a file
```javascript
import myFs from "./my-fs.js";

async function createFile() {
  myFs.docs = myFs.docs.concat({
    dir: "documents",
    filename: "report.txt",
    contents: "hello, world"
  });
}

```

Read a file
```javascript
import myFs from "./my-fs.js";

async function readFile() {
  return myFs.docs.find(file => file.dir === "/some/path" && file.filename === "report.txt");
}
```

Get all files in a directory
```javascript
import myFs from "../my-fs";

async function getFiles() {
  return myFs.docs.filter(file => file.dir === "/some/path");
}
```

Get all files in a directory recursively down to the last level of directories
```javascript
import myFs from "../my-fs";

async function getFiles() {
  return myFs.docs.filter(
    file => file.dir === "/some/path" || file.dir.startsWith("/some/path/")
  );
}
```

Update a file
```javascript
import myFs from "./my-fs.js";

async function updateFile() {
  myFs.docs = myFs.docs.map(
    file =>
      file.dir === "documents" && file.filename === "report.txt"
        ? { ...file, contents: "hello, universe" }
        : file
  );
}
```

Delete a file
```javascript
import myFs from "../my-fs";

async function deleteFile() {
  myFs.docs = myFs.docs.filter(
    file => !(file.dir === "documents" && file.filename === "report.txt")
  );
}
```

Delete a directory
```javascript
import myFs from "../my-fs";

async function deleteDir() {
  myFs.docs = myFs.docs.filter(file => !(file.dir === "documents"));
}
```

Move a file
```javascript
import myFs from "../my-fs";

async function moveFile() {
  myFs.docs = myFs.docs.map(
    file =>
      file.dir === "documents" && file.filename === "report.txt"
        ? { ...file, dir: "reports", filename: "report.txt" }
        : file
  );
}

```

Move a directory
```javascript
import myFs from "../my-fs";

async function moveFile() {
  myFs.docs = myFs.docs.map(
    file => (file.dir === "documents" ? { ...file, dir: "reports" } : file)
  );
}

```

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