download / memorystorage Goto Github PK
View Code? Open in Web Editor NEWMemory-backed storage object that implements the Web Storage API
Home Page: http://download.github.io/memorystorage
License: Creative Commons Attribution 4.0 International
Memory-backed storage object that implements the Web Storage API
Home Page: http://download.github.io/memorystorage
License: Creative Commons Attribution 4.0 International
Does anybody was creating typing for this package?
If you can install via npm, you might want to put that information in the readme. If I hadn't happened to go back to your project page to look at the links, I never would have known this was available in npm, and would have moved on to another library.
Unfortunately I rely on things like Object.keys(localStorage)
to give me the keys of all items stored.
var isolated = new MemoryStorage('my-app');
isolated.setItem("test", JSON.stringify({ key: "value" }));
Object.keys(isolated);
/// returns ["id", "length", "getItem", "setItem", "removeItem", "key", "clear", "test"]
localStorage.setItem("test", JSON.stringify({ key: "value" }));
Object.keys(localStorage);
/// returns ["test"]
It might be related, also that the output of applying JSON.stringify
is not compatile to localStorage. It should be
JSON.stringify(localStorage)
// returns {"test":"{\"key\":\"value\"}"}
but instead it is
JSON.stringify(isolated)
// returns {"id":"my-app","length":1,"test":"{\"key\":\"value\"}"}
Perhaps one should define a .toJSON
method to fix that behaviour.
With best regards
Semmel
Hi,
Looks like v0.9.10 never got pushed to NPM. Would you mind doing that?
Thanks!
Hi, I'm confused about the documentation and different header sizes. I.e. where does 'Installation' end? My troubles could be because of this.
I did:
npm install --save memorystorage
And then in my Angular CLI project ES2015:
import MemoryStorage from 'memorystorage';
....
this.storage = new MemoryStorage();
but my ng serve spits out cannot find module 'memorystorage'
. It is there in my npm folder and other packages like moment work.
Also could be a Typescript issue, ... since that't not ES2015.
In my package.json: "memorystorage": "^0.11.0",
Any ideas about this?
Using it in Chrome on Windows 10, MemoryStorage object is reset after each page update.
Should it persist across updates ?
Rationale: https://web.dev/commonjs-larger-bundles/
Some the statements below are not matching the comments. Better to tidy them up?
store.setItem('myString', 'Hello MemoryStorage!');
store.myObject = JSON.stringify({my: 'object'}));
alert(store.getItem('My string')); // alerts 'Hello MemoryStorage!'
alert(store['My string']); // alerts 'Hello MemoryStorage!'
alert(store.length); // alerts '2'
alert(store.key(1)); // alerts 'My object'
store.removeItem('My string');
alert(store.length); // alerts '1'
store.clear();
alert(store.length); // alerts '0'
With recent NPM and node updates, for example node 12.18.0
and npm 6.14.4
, there is a more strict check on the package.json
.
Error [ERR_INVALID_PACKAGE_TARGET] [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "MemoryStorage" defined in the package config /var/www/restref-site/node_modules/memorystorage/package.json; targets must start with "./"
This prevents the use of this package.
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.