Socket
Socket
Sign inDemoInstall

level-filesystem

Package Overview
Dependencies
49
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    level-filesystem

(TO BE) A full implementation of the fs module in leveldb


Version published
Weekly downloads
107K
decreased by-9.2%
Maintainers
1
Install size
1.22 MB
Created
Weekly downloads
 

Readme

Source

level-filesystem

(TO BE) A full implementation of the fs module in leveldb (except sync ops)

npm install level-filesystem

The goal of this module is similar to 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 turned out to be non-trivial (more or a less a complete rewrite).

Usage

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', function(err) {
		if (err) throw err;
		fs.readFile('/hello', '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.

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
	});
});

...

Status

// working and tested

✓ 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)

// pending

fs.ftruncate(fd, len, callback)
fs.truncate(path, len, callback)
fs.fchown(fd, uid, gid, callback)
fs.lchown(path, uid, gid, callback)
fs.fchmod(fd, mode, callback)
fs.lchmod(path, mode, callback)
fs.lstat(path, callback)
fs.fstat(fd, callback)
fs.link(srcpath, dstpath, callback)
fs.symlink(srcpath, dstpath, [type], callback)
fs.readlink(path, callback)
fs.unlink(path, callback)
fs.close(fd, callback)
fs.open(path, flags, [mode], callback)
fs.futimes(fd, atime, mtime, callback)
fs.fsync(fd, callback)
fs.write(fd, buffer, offset, length, position, callback)
fs.read(fd, buffer, offset, length, position, callback)
fs.watchFile(filename, [options], listener)
fs.unwatchFile(filename, [listener])
fs.watch(filename, [options], [listener])

License

MIT

FAQs

Last updated on 29 Mar 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc