JSPM

localforage-memoryStorageDriver

0.9.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29090
  • Score
    100M100P100Q148303F

A volatile, in memory storage driver for localForage.

Package Exports

  • localforage-memoryStorageDriver

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (localforage-memoryStorageDriver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

localforage-memoryStorageDriver

npm

A volatile, in memory storage driver for localForage.

The stored data are lost after a page reload. Originally designed for unit-testing (especially SPAs) and as a fallback for environmets without any storage APIs.

This driver serializes the stored items, so that

  • it works consistently compared to the "native" localForage driver
  • modifications of retrieved (complex) objects do not affect the stored items.

Requirements

Installation

npm i localforage-memoryStorageDriver

Example

localforage.defineDriver(memoryStorageDriver).then(function() {
  return localforage.setDriver(memoryStorageDriver._driver);
}).then(function() {
  console.log('Active driver: ' + localforage.driver());
  return localforage.setItem('test1', 'value1');
}).then(function() {
  console.log('setItem(\'test1\', \'value1\')');
  return localforage.getItem('test1');
}).then(function(value) {
  console.log('getItem(\'test1\') => ' + value);
  return localforage.clear();
})