Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

persistent-storage

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

persistent-storage

Abstracts access to any storage object implementing the webstorage Storage interface, offering optional compression using lz-string and optional encryption using crypto

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

persistent-storage

Abstracts access to any storage object implementing the webstorage Storage interface, and provides some extra features:

  • Seamless Serialisation / Deserialization of objects (functions and prototype etc however will not be maintained)
  • Optional seamless compression using lz-string
  • Optional seamless encryption using node crypto / browserify-crypto
  • Optional key scoping

Configuration

See interfaces for documentation of configuration object

Example Usage

//Without Scoping
var PersistentStore = require('persistent-store')

var store = new PersistentStorage({
        useCompression: false, 
        storageBackend: new StorageShim()
    })

store.setItem("myObj", {foo: "bar"})
console.log(store.getItem("myObj")) // Prints {foo: "bar"}


//With scoping
    
    var fred = new PersistentStorage({
            useCompression: true, 
            keyPrefix: 'fred'
            storageBackend: new StorageShim()
        })
        
    var bob = new  PersistentStorage({
            useCompression: false, 
            keyPrefix: 'bob'
            storageBackend: new StorageShim()
        })

    fred.setItem("name", "Fred")
    bob.setItem("name", "Bob")
    
    console.log(fred.getItem("name")) // prints Fred
    console.log(bob.getItem("name")) // prints  Bob
    

See unit tests here for further examples

Installation

persistent-storage is available as an npm package. Simply run:

npm install --save persistent-storage

A typescript definition file is provided with the package and will be automatically used by the typescript compiler

Running Unit Tests

The unit tests use mocha and phantomjs, and are setup to run by the standard npm test command.

npm install
npm test

You can also run them using the browser of your choice by opening the html file found here

Keywords

FAQs

Package last updated on 12 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc