# scoped-fs

> An FS wrapper that keeps all access scoped to a specific folder.

Latest version **1.4.1** (published 2019-08-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install scoped-fs
pnpm add scoped-fs
yarn add scoped-fs
bun add scoped-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.4.1 |
| Published | 2019-08-09 |
| First published | 2017-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Paul Frazee |
| Maintainers | pfraze, pfrazee |
| Keywords | files, fs, scoped |

## Links

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

## Dependencies (1)

- [recursive-watch](https://npm.io/package/recursive-watch.md) ^1.1.1

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

- 1.4.1 (latest) — 2019-08-09
- 1.4.0 — 2019-08-09
- 1.3.0 — 2018-12-08
- 1.2.0 — 2018-09-24
- 1.1.3 — 2018-05-29
- 1.1.2 — 2017-04-26
- 1.1.1 — 2017-04-26
- 1.1.0 — 2017-04-26
- 1.0.1 — 2017-04-24
- 1.0.0 — 2017-04-22

## README

# scoped-fs

An FS wrapper that keeps all access scoped to a specific folder.

```
npm install scoped-fs
```

## Usage

```js
var ScopedFS = require('scoped-fs')

var fs = new ScopedFS('/home/bob')
fs.readFile('/hello.txt', 'utf8', function (err, content) {
  // reads /home/bob/hello.txt
  console.log('world')
})
```

## API

#### `new ScopedFS(basepath)`

Creates a scoped FS instance. All reads and writes will be restricted to `basepath`; any attempts to use `..` to escape will return an error.

#### Wrapped FS methods

 - createReadStream
 - readFile
 - createWriteStream
 - writeFile
 - mkdir
 - symlink
 - access
 - exists
 - lstat
 - stat
 - readdir
 - unlink
 - rmdir

#### `var stopwatch = sfs.watch(name, fn)`

Create a [recursive-watch](https://github.com/mafintosh/recursive-watch) instance.

#### `sfs.setFilter(fn)`

Set a filtering function which causes files & folders to be hidden if the function returns false. Attempts to read a filtered file will give a not found error (ENOENT) while attempts to write will give a permissions error (EPERM).

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