It's small, easy and agnostic, runs on every framework or with vanilla Js, it automatically stringify data and if the data it's already a string, it doesn't stringify, just save the data as it is. JSI also have type anotations to help with intellisense and a mini tutorial on the lib.
TODOS:
make it selects between local and session storage✔- make better and smarter 'ifs' and/or 'switches
- make the logo
- make an Doc page an site
host it on most CDNs✔- make callbacks to give you awesome dev an granular control over the localStorage
- make more todos and finalizes these Promises() above :)
npm i jsi-just-save-it // with npm
yarn add jsi-just-save-it // better on yarn
pnpm add jsi-just-save-it // even better on pnpm
<script src="https://cdn.jsdelivr.net/npm/jsi-just-save-it"> // use it as an iife from jsdelivr
<script src="https://unpkg.com/jsi-just-save-it@1.0.0/dist/jsi.min.js"> // or from unpkg
import { useJSIStorage } from "jsi-just-save-it";
const data = {
films: ["Rogue One", "Skywalker Saga", "Solo"],
series: ["Bad Batch", "Mandalorian", "Rebels"],
games: ["Knights of the old republic", "Fallen Order", "Old Republic"],
};
const jsi = useJSIStorage();
jsi.set("sw", data); // saves it to the localStorage by default
jsi.set("sw", data, {
expire: 1000 * 60, // will expire after 1min
type: 'session', // values can be 'session' | 'local'
prefix: 'Skywalker_Saga_' // the key name will be Skywalker_Saga_sw, by default it is _JSI_
})
jsi.set("sw - films"); // throws an error, so be sure to put some data
jsi.set(data); // also throws an error, the name needs to be a string type
const spit = jsi.get("sw"); // gets it from the localStorage and automatically parses it
console.log(spit); // logs out the return of the 'let' above
jsi.remove("sw"); // remove the key, throw an if theres no key with the given name
jsi.clear(); // clear the localStorage