Home

Awesome

bro-fs

Build Status Sauce Test Status npm license

Promise-based wrapper over HTML5 Filesystem API allowing to work with sandboxed filesystem in browser.
API is similar to Node.js fs module with some extra sugar. Currently it is supported only by Chrome.

Tested in:
Sauce Test Status

Demos

API

Install

Usage

With async/await:

const fs = require('bro-fs');

(async function () {
  await fs.init({type: window.TEMPORARY, bytes: 5 * 1024 * 1024});
  await fs.mkdir('dir');
  await fs.writeFile('dir/file.txt', 'hello world');
  const content = await fs.readFile('dir/file.txt');
  console.log(content); // => "hello world"
})();

or with .then():

fs.init({type: window.TEMPORARY, bytes: 5 * 1024 * 1024})
  .then(() => fs.mkdir('dir'))
  .then(() => fs.writeFile('dir/file.txt', 'hello world'))
  .then(() => fs.readFile('dir/file.txt'))
  .then(content => console.log(content)); // => "hello world"

See more usage examples in test directory.

W3C Specs

Current:

Coming (draft):

Discussion:

Similar packages

License

MIT @ Vitaliy Potapov