# isotropy-webdisk

> Browser side lib for emulating the file system.

Latest version **0.0.8** (published 2018-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install isotropy-webdisk
pnpm add isotropy-webdisk
yarn add isotropy-webdisk
bun add isotropy-webdisk
```

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2018-01-25 |
| First published | 2017-11-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Isotropy Team |
| Maintainers | jeswin |

## Links

- npm: https://www.npmjs.com/package/isotropy-webdisk
- npm.io page: https://npm.io/package/isotropy-webdisk

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) ^8.0.57

## Recent versions

- 0.0.8 (latest) — 2018-01-25
- 0.0.7 — 2018-01-17
- 0.0.6 — 2018-01-02
- 0.0.5 — 2017-12-30
- 0.0.4 — 2017-12-29
- 0.0.3 — 2017-12-26
- 0.0.2 — 2017-12-14
- 0.0.1 — 2017-11-18

## README

# isotropy-filesystem
Browser side lib for emulating the file system.

### Setup

```javascript
const tree = {
  name: "/",
  contents: [
    {
      name: "docs",
      contents: []
    },
    {
      name: "pics",
      contents: [
        { name: "asterix.jpg", contents: "FFh D8h asterix" },
        { name: "obelix.jpg", contents: "FFh D8h obelix" },
        {
          name: "large-pics",
          contents: [
            {
              name: "asterix-large.jpg",
              contents: "FFh D8h asterix"
            },
            {
              name: "obelix-large.jpg",
              contents: "FFh D8h obelix"
            },
            {
              name: "backup",
              contents: [
                {
                  name: "asterix-large-bak.jpg",
                  contents: "FFh D8h asterix"
                },
                {
                  name: "obelix-large-bak.jpg",
                  contents: "FFh D8h obelix"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
};

webdisk.init("testdisk", tree);
```

### API

Creates a file

```javascript
const disk = await webdisk.open("testdisk");
await disk.createFile("/docs/report.txt", "Pluto is a planet.");
```

Creates or overwrites a file

```javascript
const path = "/docs/report.txt";
const filename = "report.txt";
const disk = await webdisk.open("testdisk");
await disk.createFile(path, "Pluto is a planet.", { overwrite: true });
```

Reads a file

```javascript
const path = "/docs/report.txt";
const filename = "report.txt";
const disk = await webdisk.open("testdisk");
const contents = await disk.readFile(path);
```

Reads a directory

```javascript
const path = "/pics";
const disk = await webdisk.open("testdisk");
const files = await disk.readDir(path);
files.should.deepEqual([
  "/pics/asterix.jpg",
  "/pics/obelix.jpg",
  "/pics/large-pics"
]);
```

Reads a directory recursively

```javascript
const path = "/pics";
const disk = await webdisk.open("testdisk");
const files = await disk.readDirRecursive(path);
files.should.deepEqual([
  "/pics/asterix.jpg",
  "/pics/obelix.jpg",
  "/pics/large-pics",
  "/pics/large-pics/asterix-large.jpg",
  "/pics/large-pics/obelix-large.jpg",
  "/pics/large-pics/backup",
  "/pics/large-pics/backup/asterix-large-bak.jpg",
  "/pics/large-pics/backup/obelix-large-bak.jpg"
]);
```

Creates a directory

```javascript
const path = "/pics/secret";
const disk = await webdisk.open("testdisk");
await disk.createDir(path);
```

Removes a file or directory

```javascript
const path = "/pics";
const disk = await webdisk.open("testdisk");
await disk.remove(path);
```

Moves a file or directory

```javascript
const path = "/pics/large-pics/backup";
const newPath = "/";
const disk = await webdisk.open("testdisk");
await disk.move(path, newPath);
```

Renames a file or directory

```javascript
const path = "/pics/large-pics/backup";
const newPath = "/pics/large-pics/storage";
const disk = await webdisk.open("testdisk");
await disk.move(path, newPath);
```

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