Socket
Socket
Sign inDemoInstall

bro-fs

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bro-fs

Promise-based HTML5 Filesystem API compatible with Node.js fs module


Version published
Weekly downloads
613
increased by46.3%
Maintainers
1
Install size
152 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 19 Sep 2019

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