@forlagshuset/simple-fs
File system in indexeddb
Last updated a month ago by iapain .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @forlagshuset/simple-fs 
SYNC missed versions from official npm registry.

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.

Live Demo

Supported storage backend

Simple-fs provides two storage backend. It's possible to write your own stoage backend using Storage API

  • IndexedDB (default)
import IndexedDbStorage from '@forlagshuset/simple-fs/storages/indexeddb'
  • Memory (experimental and used for testing)
import MemoryStorage from '@forlagshuset/simple-fs/storages/memory'

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>
  // by default SimpleFS uses IndexedDB
  const fs = new SimpleFS()
  // 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()

// 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

FileSystem

constructor({storage: storageObj = new IndexedDbStorage('my-storage-name')})
mkdir(path: string)
mkdirParents(path: string) // wraps mkdir -p
rmdir(path: string)
rmdirRecursive(path: string) // removes dirs recursively
readFile(path: string, options={}) // returns Blob
writeFile(path: string, data: Blob, options={}) // data should be Blob type
outputFile(path: string, data: Blob, options={}) // Wraps writeFile and recursively creates path if not exists
bulkOutputFiles([{path: string, blob: Blob, options:{}]) // Output files in one transaction, speeds up in chrome
unlink(path: string)
exists(path: string)
stats(path: string)

Browser support

  • Chrome
  • IE Edge
  • Firefox
  • Safari

Current Tags

  • 0.4.0                                ...           latest (a month ago)

27 Versions

  • 0.4.0                                ...           a month ago
  • 0.3.1                                ...           3 months ago
  • 0.2.20                                ...           3 months ago
  • 0.3.0                                ...           6 months ago
  • 0.2.19                                ...           8 months ago
  • 0.2.18                                ...           9 months ago
  • 0.2.17                                ...           a year ago
  • 0.2.16                                ...           a year ago
  • 0.2.15                                ...           a year ago
  • 0.2.14                                ...           a year ago
  • 0.2.13                                ...           a year ago
  • 0.2.12                                ...           a year ago
  • 0.2.11                                ...           a year ago
  • 0.2.10                                ...           2 years ago
  • 0.2.9                                ...           2 years ago
  • 0.2.8                                ...           2 years ago
  • 0.2.7                                ...           2 years ago
  • 0.2.6                                ...           2 years ago
  • 0.2.5                                ...           2 years ago
  • 0.2.4                                ...           2 years ago
  • 0.2.3                                ...           2 years ago
  • 0.2.2                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.10                                ...           2 years ago
  • 0.1.9                                ...           2 years ago
  • 0.1.8                                ...           2 years ago
  • 0.1.7                                ...           2 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 9
Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |