svelte-persisted-store
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -11,2 +11,3 @@ import { Writable } from 'svelte/store'; | ||
storage?: StorageType; | ||
syncTabs: boolean; | ||
} | ||
@@ -17,2 +18,2 @@ /** @deprecated `writable()` has been renamed to `persisted()` */ | ||
export { persisted, writable }; | ||
export { Options, Serializer, StorageType, persisted, writable }; |
@@ -40,5 +40,6 @@ "use strict"; | ||
function persisted(key, initialValue, options) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
const serializer = (_a = options == null ? void 0 : options.serializer) != null ? _a : JSON; | ||
const storageType = (_b = options == null ? void 0 : options.storage) != null ? _b : "local"; | ||
const syncTabs = (_c = options == null ? void 0 : options.syncTabs) != null ? _c : true; | ||
const browser = typeof window !== "undefined" && typeof document !== "undefined"; | ||
@@ -55,3 +56,3 @@ const storage = browser ? getStorage(storageType) : null; | ||
} | ||
if (browser && storageType == "local") { | ||
if (browser && storageType == "local" && syncTabs) { | ||
const handleStorage = (event) => { | ||
@@ -58,0 +59,0 @@ if (event.key === key) |
{ | ||
"name": "svelte-persisted-store", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"license": "MIT", | ||
@@ -25,7 +25,7 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.21.0", | ||
"@babel/core": "^7.23.3", | ||
"@babel/preset-env": "^7.18.6", | ||
"@typescript-eslint/eslint-plugin": "^5.54.0", | ||
"@typescript-eslint/parser": "^5.59.8", | ||
"@vitest/coverage-v8": "^0.32.0", | ||
"@typescript-eslint/parser": "^5.62.0", | ||
"@vitest/coverage-v8": "^0.34.6", | ||
"codecov": "^3.8.3", | ||
@@ -32,0 +32,0 @@ "eslint": "^8.50.0", |
@@ -50,3 +50,4 @@ [![npm version](https://img.shields.io/npm/v/svelte-persisted-store.svg)](https://www.npmjs.com/package/svelte-persisted-store) [![license](https://img.shields.io/npm/l/svelte-persisted-store.svg)](LICENSE.md) [![codecov](https://codecov.io/gh/joshnuss/svelte-persisted-store/branch/master/graph/badge.svg?token=GU607D2YRQ)](https://codecov.io/gh/joshnuss/svelte-persisted-store) | ||
serializer: devalue, // defaults to `JSON` | ||
storage: 'session' // 'session' for sessionStorage, defaults to 'local' | ||
storage: 'session', // 'session' for sessionStorage, defaults to 'local' | ||
syncTabs: true // choose wether to sync localStorage across tabs, default is true | ||
}) | ||
@@ -53,0 +54,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
18866
160
58