localstorage-fs

0.1.0 • Public • Published

localstorage-fs

node's fs module backed by localStorage

Browser Support

why

this would be way better, but i needed the sync methods

how

browserify and use like you would in node land

api coverage

  • fs.rename(oldPath, newPath, callback)
  • fs.renameSync(oldPath, newPath)
  • fs.truncate(path, len, callback)
  • fs.truncateSync(path, len)
  • fs.chmod(path, mode, callback)
  • fs.chmodSync(path, mode)
  • fs.stat(path, callback)
  • fs.statSync(path)
  • fs.unlink(path, callback)
  • fs.unlinkSync(path)
  • fs.rmdir(path, callback)
  • fs.rmdirSync(path)
  • fs.mkdir(path, callback)
  • fs.mkdirSync(path, mode)
  • fs.readdir(path, callback)
  • fs.readdirSync(path)
  • fs.readFile(path, options, callback)
  • fs.readFileSync(path, options)
  • fs.writeFile(path, data, options, callback)
  • fs.writeFileSync(path, data, options)
  • fs.appendFile(path, data, options, callback)
  • fs.appendFileSync(path, data, options)
  • fs.exists(path, callback)
  • fs.existsSync(path)
  • fs.createWriteStream(path, options)
  • fs.createReadStream(path, options)

others that could probably be implemented here

tests / example

  • get browserify
  • get bash
  • npm run test
  • npm run example

implementation

  • file data and directory listings are keyed by '/path/name' under the prefix: 'file://'
  • meta data (also keyed by path name) is stored as JSON stringified fs.Stats instances under 'file-meta://'
  • file contents are stored as base64 encoded strings which means binary files work
  • directory listings are stored as newline delimited plain strings (like ls(1))
  • async methods are faked with process.nextTick
  • streams are faked by buffering into memory

notes

  • some fs related process methods are shimmed out by this module for now

license

WTFPL

Readme

Keywords

none

Package Sidebar

Install

npm i localstorage-fs

Weekly Downloads

121

Version

0.1.0

License

WTFPL

Last publish

Collaborators

  • jessetane