dxos-deprecated / random-access-multi-storage

GNU Affero General Public License v3.0
1 stars 2 forks source link

Random Access Multi Storage

Build Status Coverage Status Greenkeeper badge js-semistandard-style standard-readme compliant

Factory for creating platform-specific random-access-storage files.

Install

$ npm install @dxos/random-access-multi-storage

Usage

import { createStorage } from '@dxos/random-access-multi-storage';

const storage = createStorage('./dir');

const file = storage('test.txt')
file.write(0, Buffer('hello'), err => {
  file.read(0, 5, (err, data) => {
    console.log(data.toString())
  })
});

API

createStorage(rootPath: String, storageType?: StorageType) => RandomAccessStorage

Create a RandomAccessStorage based in the storageType. If storageType is not specified, return a default RandomAccessStorage depending on the environment.

Available storages:

import { STORAGE_CHROME, STORAGE_FIREFOX, ... } from '@dxos/random-access-multi-storage'

Contributing

PRs accepted.

License

GPL-3.0 © dxos