jherax / proxy-storage Goto Github PK
View Code? Open in Web Editor NEWProvides an adapter for storage mechanisms (cookies, localStorage, sessionStorage, memoryStorage) and implements the Web Storage interface
License: MIT License
Provides an adapter for storage mechanisms (cookies, localStorage, sessionStorage, memoryStorage) and implements the Web Storage interface
License: MIT License
When I try to get an existent cookie that has plain text as value, I get the following error:
SyntaxError: Unexpected token l in JSON
const cookieStore = new WebStorage('cookieStorage');
let address = cookieStore.getItem('userAddress')
// throws error
When trying to delete a cookie created by setting options.domain
or options.path
it is not working.
const cookieStore = new WebStorage('cookieStorage');
cookieStore.setItem('testing', [1,4,7], {
domain: '.wordpress.com',
expires: { minutes: 10 },
});
cookieStore.getItem('testing'); // ok, it exists
cookieStore.removeItem('testing'); // failing!
cookieStore.getItem('testing'); // failing, still exists!
As memoryStorage
has a similar behavior to sessionStorage
, it should be the default fallback when WebStorage
is not available.
Currently cookieStorage
is the fallback.
It is necessary that when creating a new instance of cookieStorage
, the method getAll()
be called upon the instance, to get all elementes updated.
When you create a new instance of a storage mechanism, you don't have access to existing elements, for example:
// previous element
localStorage.setItem('test', "some value");
// create a new instance of the proxy
const localStore = new WebStorage('localStorage');
Object.keys(localStore).forEach((key) => console.log(key, localStore[key]));
Expected: "test" "some value"
, but got undefined
When I try to retrieve a value that not exist in the cookies store, i get the following error:
Uncaught SyntaxError: Unexpected token u in JSON at position 0...
For example:
var cookieStore = new proxyStorage.WebStorage("cookieStorage");
cookieStore.getItem('nothing-here');
// expected: null
// got: an exception
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.