Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/realfakenerd/jsi
Local | Session storage wrapper with great features
https://github.com/realfakenerd/jsi
javascript localstorage storage-api storage-manager
Last synced: 11 days ago
JSON representation
Local | Session storage wrapper with great features
- Host: GitHub
- URL: https://github.com/realfakenerd/jsi
- Owner: realfakenerd
- License: mit
- Created: 2022-01-18T03:10:55.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-24T21:51:30.000Z (about 3 years ago)
- Last Synced: 2025-01-22T05:16:00.662Z (14 days ago)
- Topics: javascript, localstorage, storage-api, storage-manager
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/jsi-just-save-it
- Size: 70.3 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# JSI[just,save,it] (͠≖ ͜ʖ͠≖)👌
## The most SUPER SUPREME of all Storage wrappers
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 :)## Instalation:
```js
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
// use it as an iife from jsdelivr
<script src="https://unpkg.com/[email protected]/dist/jsi.min.js"> // or from unpkg```
## Usage:
```js
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
```