Skip to content
Handles files on indexeddb like you would do in node.js (promise)
Branch: master
Clone or download
Latest commit 6bf905f Mar 22, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE docs: Update issue templates Jun 30, 2018
src Merge pull request #3 from fagbokforlaget/delete_recursively Jan 29, 2019
test/unit single quotes Mar 21, 2019
.editorconfig
.eslintignore
.eslintrc.js init project May 18, 2018
.flowconfig fix: npm deps update Mar 11, 2019
.gitignore init project May 18, 2018
.npmignore
.travis.yml
AUTHORS
CODE_OF_CONDUCT.md docs: adds code of conduct Jun 30, 2018
LICENSE Initial commit May 17, 2018
README.md docs: updates readme Mar 13, 2019
babel.config.js build: build shortcuts and proper env Feb 27, 2019
index.html docs: consistent documentation Mar 13, 2019
package-lock.json
package.json
rollup.config.js
webpack.config.js

README.md

SimpleFS

view on npm npm module downloads Dependency Status Known Vulnerabilities Build Status License: MIT

A minimal, extensible and promise based filesystem layer for modern browsers.

Supported backeneds

  • IndexedDB (default)
  • Memory (experimental and used for testing)

Installation

npm:

npm install --save @forlagshuset/simple-fs

Usage

browser (umd):

<script src='https://unpkg.com/@forlagshuset/simple-fs@latest/dist/SimpleFS.min.js' async></script>
<script>
  const fs = new SimpleFS({name:'storage-name'})
  // do stuff

  await fs.mkdir('/myproject')

  // create a file under root folder
  const content = new Blob(['This is my cool project'], {type: 'plain/text'})
  await fs.writeFile('/myproject/test.txt', content)

  // get content as blob
  let blob = await fs.readFile('/myproject/test.txt')

</script>

browser (modules)

import SimpleFS from '@forlagshuset/simple-fs'
// OR es6 modules from unpkg
import SimpleFS from "//unpkg.com/@forlagshuset/simple-fs?module"

const fs = new SimpleFS({name: 'storage-name'})

// first create root folder
await fs.mkdir('/myproject')

// create a file under root folder
const content = new Blob(['This is my cool project'], {type: 'plain/text'})
await fs.writeFile('/myproject/test.txt', content)

// get content as blob
let blob = await fs.readFile('/myproject/test.txt')

API

mkdir(<path>)
mkdirParents(<path>) // wraps mkdir -p
rmdir(<path>)
rmdirRecursive(<path>) // removes dirs recursively
readFile(<path>, <options>={}) // returns Blob
writeFile(<path>, <data>, <options>={}) // data should be Blob type
outputFile(<path>, <data>, <options>={}) // Wraps writeFile and recursively creates path if not exists
unlink(<path>)
exists(<path>)
stats(<path>)

Browser support

  • Chrome
  • IE Edge
  • Firefox
  • Safari
You can’t perform that action at this time.