@dxos/random-access-multi-storage

Multiple random storage types.

Usage no npm install needed!

<script type="module">
  import dxosRandomAccessMultiStorage from 'https://cdn.skypack.dev/@dxos/random-access-multi-storage';
</script>

README

Random Access Multi Storage

Build Status 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.

  • rootPath: Root path to store the files.
  • storageType: Storage type.

Available storages:

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

Contributing

PRs accepted.

License

GPL-3.0 © dxos