
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
A tiny ~300b unistore persistence helper library state container with various storage adapters.
This project uses node and npm. Go check them out if you don't have them locally installed.
npm install --save unissist
Then with a module bundler like webpack or rollup, use as you would anything else:
// The helper:
import persistStore from 'unissist';
// localStorage Adapter
import localStorageAdapter from 'unissist/integrations/localStorageAdapter';
// indexedDB Adapter
import indexedDBAdapter from 'unissist/integrations/indexdbAdapter';
// AsyncStorage Adapter
import asyncStorageAdapter from 'unissist/integrations/asyncStorageAdapter';
The UMD build is also available on unpkg:
<script src="//unpkg.com/unistore/dist/unissist.umd.js"></script>
You can find the library on window.unissist
.
// use unistore like you always would, but use the unissist helper to persist state
import createStore from 'unistore'
import persistStore from 'unissist'
import localStorageAdapter from 'unissist/integrations/localStorageAdapter';
const store = createStore({ count: 0 })
const adapter = localStorageAdapter();
persistStore(store, adapter);
// store state now includes a `hydrated` that tells you whether or not the state has been rehydrated from the store
Unissist also takes a third parameter that allows you to configure how your peristence works
import createStore from 'unistore'
import persistStore from 'unissist'
import localStorageAdapter from 'unissist/integrations/localStorageAdapter';
const store = createStore({ count: 0 })
const adapter = localStorageAdapter();
// Default values except migration
let config = {
version: 1,
debounceTime: 100,
// called when version is updated. Accepts promises. Defaults to dropping the store
migration: (oldState, oldversion) => ({ /* new state */ }),
// takes in the current state and returns the state to be persisted
map: state => ({ /* new persisted state shape */ })
// takes in state that will be hydrated and returns the new state shape
hydration: state => ({ /* new state shape */ })
}
persistStore(store, adapter, config);
Found a problem? Want a new feature? First of all, see if your issue or idea has already been reported. If not, just open a new clear and descriptive issue.
Jason Miller for unistore, assign
util function, and a lot of the tooling that I stole used
Jake Archibald for idb-keyval where much of the code for the indexdbAdapter was stolen borrowed
Sean Groff for the name
FAQs
A persistance library for unistore
We found that unissist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.