0.2.0 • Published 5 years ago

random-access-storage-proxy v0.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

random-access-storage-proxy

Proxy random access storage requests dynamically.

Installation

$ npm install random-access-storage-proxy

Usage

const storage = proxy([target])

API

storage = proxy([target])

Creates a proxy random access storage object that dynamically proxies open(), close(), destroy(), read(), write(), stat(), and del() requests to target, if given. If target is not given, a target can be set with storage.setTarget(target).

Storage state properties like writable, readable, statable, and deletable are configured to match the target state properties. Proxy implementation methods like _write(), _read(), _stat(), and _del are set to the original default implementation for a random-access-storage object when target lacks one.

Example:

// initialize proxy with 'random-access-storage'
const store = proxy(ram())

// initialize proxy to target read only storage
store.setTarget(raf('path/to/file', { writable: false }))

storage.setTarget(target)

Sets proxy target, reconfigures and restore storage state properties and methods.

store.setTarget(ram())
store.setTarget(raf(filename))
store.setTarget(rah(url))

storage.reset()

Resets the proxy storage state to the default random-access-storage implementation state.

storage.reset()

License

MIT