bro-fs
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/bro-fs package

0.6.0 • Public • Published

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

  • install from npm:
    npm install bro-fs
  • include directly from CDN via <script> tag:
    <script src="https://unpkg.com/bro-fs"></script>
  • download manually the latest release

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

Dependencies (0)

    Dev Dependencies (28)

    Package Sidebar

    Install

    npm i bro-fs

    Weekly Downloads

    163

    Version

    0.6.0

    License

    MIT

    Unpacked Size

    155 kB

    Total Files

    15

    Last publish

    Collaborators

    • vitalets