All Projects → DonnieWest → Unissist

DonnieWest / Unissist

⛑ A ~300b unistore helper to persist your data using equally tiny storage adapters

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Unissist

Moor
Moor is an easy to use, reactive, typesafe persistence library for Dart & Flutter
Stars: ✭ 1,090 (+1059.57%)
Mutual labels:  persistence
Printf
Tiny, fast, non-dependent and fully loaded printf implementation for embedded systems. Extensive test suite passing.
Stars: ✭ 1,157 (+1130.85%)
Mutual labels:  tiny
Lightdm Tiny Greeter
👋 A Tiny GTK3 LightDM Greeter
Stars: ✭ 83 (-11.7%)
Mutual labels:  tiny
Tinano
A typesafe sqlite persistence library for flutter
Stars: ✭ 59 (-37.23%)
Mutual labels:  persistence
Smoldash
Smoldash, A tiny lodash alternative built for the modern web
Stars: ✭ 66 (-29.79%)
Mutual labels:  tiny
Drain3
Drain log template miner in Python3
Stars: ✭ 71 (-24.47%)
Mutual labels:  persistence
Backbone Faux Server
A framework for mocking up server-side persistence / processing for Backbone.js
Stars: ✭ 55 (-41.49%)
Mutual labels:  persistence
Tiny Cookie
A tiny cookie manipulation plugin for the browser.
Stars: ✭ 90 (-4.26%)
Mutual labels:  tiny
Vue Cosha
🎨 A vue directive for the cosha library
Stars: ✭ 64 (-31.91%)
Mutual labels:  tiny
Cistern
Ruby API client framework
Stars: ✭ 81 (-13.83%)
Mutual labels:  persistence
Dr0p1t Framework
A framework that create an advanced stealthy dropper that bypass most AVs and have a lot of tricks
Stars: ✭ 1,132 (+1104.26%)
Mutual labels:  persistence
Nanvix
Educational Spinoff of Nanvix
Stars: ✭ 65 (-30.85%)
Mutual labels:  tiny
Phpsploit
Full-featured C2 framework which silently persists on webserver with a single-line PHP backdoor
Stars: ✭ 1,188 (+1163.83%)
Mutual labels:  persistence
Clc
Tiny bash utility for coloring terminal output and prompt
Stars: ✭ 58 (-38.3%)
Mutual labels:  tiny
Tupl
The Unnamed Persistence Library
Stars: ✭ 83 (-11.7%)
Mutual labels:  persistence
Genann
simple neural network library in ANSI C
Stars: ✭ 1,088 (+1057.45%)
Mutual labels:  tiny
Query Validator
Compile time validation for HQL and JPQL queries in Java code
Stars: ✭ 70 (-25.53%)
Mutual labels:  persistence
Pyclue
Python toolkit for Chinese Language Understanding(CLUE) Evaluation benchmark
Stars: ✭ 91 (-3.19%)
Mutual labels:  tiny
Hibernate Performance
Samples for "Hibernate performance tuning" talk
Stars: ✭ 87 (-7.45%)
Mutual labels:  persistence
Winpayloads
Undetectable Windows Payload Generation
Stars: ✭ 1,211 (+1188.3%)
Mutual labels:  persistence

npm travis

unissist

A tiny ~300b unistore persistence helper library state container with various storage adapters.

Table of Contents

Install

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.

Usage

// 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);

Reporting Issues

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.

Credits

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

License

MIT License © Donnie West

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].