{"id":13726024,"url":"https://github.com/DonnieWest/unissist","last_synced_at":"2025-05-07T21:30:55.348Z","repository":{"id":28660158,"uuid":"117906539","full_name":"DonnieWest/unissist","owner":"DonnieWest","description":"⛑ A ~300b unistore helper to persist your data using equally tiny storage adapters","archived":false,"fork":false,"pushed_at":"2022-12-07T09:11:21.000Z","size":2196,"stargazers_count":93,"open_issues_count":22,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-11T20:16:06.137Z","etag":null,"topics":["persistence","tiny","unistore"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DonnieWest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-17T23:46:27.000Z","updated_at":"2023-09-08T17:35:21.000Z","dependencies_parsed_at":"2022-09-15T07:20:25.145Z","dependency_job_id":null,"html_url":"https://github.com/DonnieWest/unissist","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DonnieWest%2Funissist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DonnieWest%2Funissist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DonnieWest%2Funissist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DonnieWest%2Funissist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DonnieWest","download_url":"https://codeload.github.com/DonnieWest/unissist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224654062,"owners_count":17347662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["persistence","tiny","unistore"],"created_at":"2024-08-03T01:02:48.290Z","updated_at":"2024-11-14T16:33:07.452Z","avatar_url":"https://github.com/DonnieWest.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003ca href=\"https://www.npmjs.org/package/unissist\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/unissist.svg?style=flat\" alt=\"npm\"\u003e\u003c/a\u003e \u003ca href=\"https://travis-ci.org/DonnieWest/unissist\"\u003e\u003cimg src=\"https://api.travis-ci.org/DonnieWest/unissist.svg?branch=master\" alt=\"travis\"\u003e\u003c/a\u003e\n\n# unissist\n\n\u003e A tiny ~300b unistore persistence helper library state container with various storage adapters.\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n- [License](#license)\n\n## Install\n\nThis project uses [node](http://nodejs.org) and [npm](https://npmjs.com). Go check them out if you don't have them locally installed.\n\n```sh\nnpm install --save unissist\n```\n\nThen with a module bundler like [webpack](https://webpack.js.org) or [rollup](http://rollupjs.org), use as you would anything else:\n\n```js\n// The helper:\nimport persistStore from 'unissist';\n\n// localStorage Adapter\nimport localStorageAdapter from 'unissist/integrations/localStorageAdapter';\n\n// indexedDB Adapter\nimport indexedDBAdapter from 'unissist/integrations/indexdbAdapter';\n\n// AsyncStorage Adapter\nimport asyncStorageAdapter from 'unissist/integrations/asyncStorageAdapter';\n```\n\nThe [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com):\n\n```html\n\u003cscript src=\"//unpkg.com/unistore/dist/unissist.umd.js\"\u003e\u003c/script\u003e\n```\n\nYou can find the library on `window.unissist`.\n\n### Usage\n\n```js\n// use unistore like you always would, but use the unissist helper to persist state\nimport createStore from 'unistore'\nimport persistStore from 'unissist'\nimport localStorageAdapter from 'unissist/integrations/localStorageAdapter';\n\nconst store = createStore({ count: 0 })\nconst adapter = localStorageAdapter();\n\npersistStore(store, adapter);\n\n// store state now includes a `hydrated` that tells you whether or not the state has been rehydrated from the store\n```\n\nUnissist also takes a third parameter that allows you to configure how your peristence works\n\n```js\nimport createStore from 'unistore'\nimport persistStore from 'unissist'\nimport localStorageAdapter from 'unissist/integrations/localStorageAdapter';\n\nconst store = createStore({ count: 0 })\nconst adapter = localStorageAdapter();\n\n// Default values except migration\nlet config = {\n  version: 1,\n  debounceTime: 100,\n  // called when version is updated. Accepts promises. Defaults to dropping the store\n  migration: (oldState, oldversion) =\u003e ({ /* new state */ }),\n  // takes in the current state and returns the state to be persisted\n  map: state =\u003e ({ /* new persisted state shape */ })\n  // takes in state that will be hydrated and returns the new state shape\n  hydration: state =\u003e ({ /* new state shape */ })\n}\n\npersistStore(store, adapter, config);\n\n```\n\n### Reporting Issues\n\nFound a problem? Want a new feature? First of all, see if your issue or idea has [already been reported](../../issues).\nIf not, just open a [new clear and descriptive issue](../../issues/new).\n\n### Credits\n\n[Jason Miller](https://github.com/developit) for [unistore](https://github.com/developit/unistore), `assign` util function, and a lot of the tooling that I ~stole~ used\n\u003c/br\u003e\n[Jake Archibald](https://github.com/jakearchibald) for [idb-keyval](https://github.com/jakearchibald/idb-keyval) where much of the code for the indexdbAdapter was ~stolen~ borrowed\n\u003c/br\u003e\n[Sean Groff](https://github.com/seangroff) for the name\n\n### License\n\n[MIT License](https://oss.ninja/mit/donniewest) © [Donnie West](https://donniewest.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDonnieWest%2Funissist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDonnieWest%2Funissist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDonnieWest%2Funissist/lists"}