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) 817 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const LocalStoragePersist = require("./persist/LocalStoragePersist.js"); const SessionStoragePersist = require("./persist/SessionStoragePersist.js"); 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; }; exports.applyPersist = applyPersist;