UNPKG

@naverpay/vanilla-store

Version:

![NPM Version](https://img.shields.io/npm/v/%40naverpay%2Fvanilla-store) ![NPM bundle size](https://img.shields.io/bundlephobia/min/%40naverpay%2Fvanilla-store) ![NPM Downloads](https://img.shields.io/npm/dw/%40naverpay%2Fvanilla-store)

21 lines (20 loc) 712 B
import LocalStoragePersist from "./persist/LocalStoragePersist.mjs"; import SessionStoragePersist from "./persist/SessionStoragePersist.mjs"; const applyPersist = (options = {}, addCallbacks, initialState) => { let persistStore = null; if (options?.persist) { const key = options.persist.key; if (options.persist.type === "localStorage") { persistStore = new LocalStoragePersist(key, initialState, options.persist.typeAssertion); addCallbacks(); } if (options.persist.type === "sessionStorage") { persistStore = new SessionStoragePersist(key, initialState, options.persist.typeAssertion); addCallbacks(); } } return persistStore; }; export { applyPersist };