# level-filesystem

> Full implementation of the fs module on top of leveldb

Latest version **1.2.0** (published 2015-12-01) · 0 weekly downloads

## Install

```sh
npm install level-filesystem
pnpm add level-filesystem
yarn add level-filesystem
bun add level-filesystem
```

## 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.2.0 |
| Published | 2015-12-01 |
| First published | 2014-03-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 166 |
| Maintainers | mafintosh |
| Keywords | leveldb, level, filesystem, fs, file, replacement |

## Links

- npm: https://www.npmjs.com/package/level-filesystem
- Repository: https://github.com:mafintosh/level-filesystem
- Homepage: https://github.com/mafintosh/level-filesystem
- Issues: https://github.com/mafintosh/level-filesystem/issues
- npm.io page: https://npm.io/package/level-filesystem

## Dependencies (9)

- [once](https://npm.io/package/once.md) ^1.3.0
- [errno](https://npm.io/package/errno.md) ^0.1.1
- [octal](https://npm.io/package/octal.md) ^1.0.0
- [xtend](https://npm.io/package/xtend.md) ^2.2.0
- [fwd-stream](https://npm.io/package/fwd-stream.md) ^1.0.4
- [level-peek](https://npm.io/package/level-peek.md) ^1.0.6
- [level-blobs](https://npm.io/package/level-blobs.md) ^0.1.7
- [concat-stream](https://npm.io/package/concat-stream.md) ^1.4.4
- [level-sublevel](https://npm.io/package/level-sublevel.md) ^5.2.0

## 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.2.0 (latest) — 2015-12-01
- 1.1.0 — 2014-10-11
- 1.0.2 — 2014-10-10
- 1.0.1 — 2014-04-14
- 1.0.0 — 2014-04-14
- 0.0.4 — 2014-04-13
- 0.0.3 — 2014-04-12
- 0.0.2 — 2014-03-29
- 0.0.1 — 2014-03-29
- 0.0.0 — 2014-03-29

## README

# level-filesystem

Full implementation of the fs module on top of leveldb (except sync ops)

	npm install level-filesystem

[![build status](http://img.shields.io/travis/mafintosh/level-filesystem.svg?style=flat)](http://travis-ci.org/mafintosh/level-filesystem)
![dat](http://img.shields.io/badge/Development%20sponsored%20by-dat-green.svg?style=flat)


[![browser support](https://ci.testling.com/mafintosh/level-filesystem.png)
](https://ci.testling.com/mafintosh/level-filesystem)

## Current status

All async methods in the fs module are supported and well tested (including links!)

```
✓ fs.rmdir(path, callback)
✓ fs.mkdir(path, [mode], callback)
✓ fs.readdir(path, callback)
✓ fs.stat(path, callback)
✓ fs.exists(path, callback)
✓ fs.chmod(path, mode, callback)
✓ fs.chown(path, uid, gid, callback)
✓ fs.rename(oldPath, newPath, callback)
✓ fs.realpath(path, [cache], callback)
✓ fs.readFile(filename, [options], callback)
✓ fs.writeFile(filename, data, [options], callback)
✓ fs.appendFile(filename, data, [options], callback)
✓ fs.utimes(path, atime, mtime, callback)
✓ fs.unlink(path, callback)
✓ fs.createReadStream(path, [options])
✓ fs.createWriteStream(path, [options])
✓ fs.truncate(path, len, callback)
✓ fs.watchFile(filename, [options], listener)
✓ fs.unwatchFile(filename, [listener])
✓ fs.watch(filename, [options], [listener])
✓ fs.fsync(fd, callback)
✓ fs.write(fd, buffer, offset, length, position, callback)
✓ fs.read(fd, buffer, offset, length, position, callback)
✓ fs.close(fd, callback)
✓ fs.open(path, flags, [mode], callback)
✓ fs.futimes(fd, atime, mtime, callback)
✓ fs.fchown(fd, uid, gid, callback)
✓ fs.ftruncate(fd, len, callback)
✓ fs.fchmod(fd, mode, callback)
✓ fs.fstat(fd, callback)
✓ fs.lchown(path, uid, gid, callback)
✓ fs.lchmod(path, mode, callback)
✓ fs.symlink(srcpath, dstpath, [type], callback)
✓ fs.lstat(path, callback)
✓ fs.readlink(path, callback)
✓ fs.link(srcpath, dstpath, callback)
```

If any of the methods do not behave as you would expect please add a test case or open an issue.

## Usage

``` js
var filesystem = require('level-filesystem');
var fs = filesystem(db); // where db is a levelup instance

// use fs as you would node cores fs module

fs.mkdir('/hello', function(err) {
	if (err) throw err;
	fs.writeFile('/hello/world.txt', 'world', function(err) {
		if (err) throw err;
		fs.readFile('/hello/world.txt', 'utf-8', function(err, data) {
			console.log(data);
		});
	});
});
```

## Errors

When you get an error in a callback it is similar to what you get in Node core fs.

``` js
fs.mkdir('/hello', function() {
	fs.mkdir('/hello', function(err) {
		console.log(err); // err.code is EEXIST
	});
});

fs.mkdir('/hello', function() {
	fs.readFile('/hello', function(err) {
		console.log(err); // err.code is EISDIR
	});
});

...
```

## Relation to level-fs

The goal of this module is similar to [level-fs](https://github.com/juliangruber/level-fs) and is probably gonna end up as a PR to that module.
I decided to make this as a standalone module (for now) since adding proper directory support to [level-fs](https://github.com/juliangruber/level-fs)
turned out to be non-trivial (more or a less a complete rewrite).


## License

MIT

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