gr2m / gr2m/localstorage-memory

Unable to create multiple instances

Open
#1 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
26
Forks
6
PR merge metrics
No merged PRs in 30d

Description

Would you be open to a PR that enabled multiple instances?

The API for localstorage and sessionstorage is identical. We're using this module in for our node test suite to mock out local and session storage. However, because this module acts as a singleton, we can't create separate stores (one to mock localStorage and another for sessionStorage).

Changing up the api of this so that it's possible to instantiate any number of stores would be greatly beneficial.

Something like:

``` js
var Storage = require('localstorage-memory');

var localStorage = new Storage();
var sessionStorage = new Storage();

localStorage.setItem('foo', 'bar');
sessionStorage.getItem('foo'); // -> undefined
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.