8000 GitHub - m10316008/bro-fs: Promise-based HTML5 Filesystem API similar to Node.js fs module
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

m10316008/bro-fs

 
 

Repository files navigation

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

About

Promise-based HTML5 Filesystem API similar to Node.js fs module

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%
0