2.0.0-beta.3 • Published 4 years ago

@dxos/random-access-chrome-file v2.0.0-beta.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

random-access-chrome-file

Build Status JavaScript Style Guide

A random-access-storage instance backed by the Chrome file system api

npm install random-access-chrome-file

Usage

// Currently only works in Chrome

const createFile = require('random-access-chrome-file')

const file = createFile('test.txt')

file.write(0, Buffer.from('hello world'), function (err) {
  if (err) throw err
  file.read(0, 11, function (err, buf) {
    if (err) throw err
    console.log(buf.toString())
  })
})

API

file = createFile(name, [options])

Returns a random-access-storage instance that supports the full API.

Options include:

{
  maxSize: Number.MAX_SAFE_INTEGER
}

maxSize is the storage quota it asks the browser for. If you are making an extension you can set the unlimitedStorage to get all the storage you want. Otherwise tweak the maxSize option to fit your needs.

If you want to change the maxSize default for all instances change createFile.DEFAULT_MAX_SIZE.

createFile.requestQuota(maxSize, cb)

Manually request the maxSize quota without creating af file.

License

MIT

2.0.0-beta.2

4 years ago

2.0.0-beta.3

4 years ago

2.0.0-beta.1

4 years ago

2.0.0-beta.0

4 years ago