0.2.1 • Published 2 years ago
storage-factory v0.2.1
storage-factory
This library is a tiny (414B) wrapper for localStorage
and sessionStorage
because using Storage directly is a bad idea. Here's the blogpost that explains why is that.
Warning: object access (e.g. localStorage.foo
) is not yet implemented 💥
Usage
Somewhere in your project
// storage.js
import { storageFactory } from "storage-factory";
export const local = storageFactory(() => localStorage);
export const session = storageFactory(() => sessionStorage);
When you need to use storage
import * as storage from "./storage";
function login(token) {
storage.local.setItem("token", token);
// do your other login things
}
Example
Run the example using parcel
npx parcel example/index.html
Contribute
Do you want to contribute? Awesome! Please, create an issue first and tell me about it.
0.2.1
2 years ago
0.2.0
3 years ago
0.2.0-beta.2
3 years ago
0.2.0-beta.1
3 years ago
0.2.0-beta.0
3 years ago
0.1.1
4 years ago
0.1.0
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2
6 years ago
0.0.1
6 years ago