svelte-local-storage-store
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -85,5 +85,12 @@ (function (global, factory) { | ||
function updateStorage(key, value) { | ||
if (typeof(localStorage) == 'undefined') | ||
return | ||
localStorage.setItem(key, JSON.stringify(value)); | ||
} | ||
return { | ||
set(value) { | ||
typeof(localStorage) != 'undefined' ? localStorage.setItem(key, JSON.stringify(value)) : null; | ||
updateStorage(key, value); | ||
set(value); | ||
@@ -93,3 +100,5 @@ }, | ||
const value = cb(get_store_value(store)); | ||
this.set(value); | ||
updateStorage(key, value); | ||
set(value); | ||
}, | ||
@@ -96,0 +105,0 @@ subscribe |
{ | ||
"name": "svelte-local-storage-store", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"svelte": "src/index.js", | ||
@@ -10,8 +10,25 @@ "module": "dist/index.mjs", | ||
"prepublishOnly": "npm run build", | ||
"lint": "eslint . --ext .js,.svelte" | ||
"lint": "eslint . --ext .js,.svelte", | ||
"test": "jest", | ||
"test:watch": "yarn run test -- --watch" | ||
}, | ||
"jest": { | ||
"testMatch": [ | ||
"<rootDir>/test/*.test.js" | ||
], | ||
"transform": { | ||
"^.+\\.js$": "babel-jest" | ||
}, | ||
"moduleFileExtensions": [ | ||
"js" | ||
] | ||
}, | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.11.5", | ||
"@rollup/plugin-node-resolve": "^6.0.0", | ||
"babel-jest": "^26.5.2", | ||
"eslint": "^7.3.1", | ||
"eslint-plugin-jest": "^24.1.0", | ||
"eslint-plugin-svelte3": "^2.7.3", | ||
"jest": "^26.5.2", | ||
"rollup": "^2.18.0", | ||
@@ -18,0 +35,0 @@ "rollup-plugin-svelte": "^5.0.0", |
@@ -43,3 +43,2 @@ # svelte-local-storage-store | ||
- [ ] Support multiple tabs / capture event when localStorage changes | ||
- [ ] Add tests | ||
@@ -46,0 +45,0 @@ ## License |
@@ -12,5 +12,12 @@ import {writable as internal, get} from 'svelte/store' | ||
function updateStorage(key, value) { | ||
if (typeof(localStorage) == 'undefined') | ||
return | ||
localStorage.setItem(key, JSON.stringify(value)) | ||
} | ||
return { | ||
set(value) { | ||
typeof(localStorage) != 'undefined' ? localStorage.setItem(key, JSON.stringify(value)) : null | ||
updateStorage(key, value) | ||
set(value) | ||
@@ -20,3 +27,5 @@ }, | ||
const value = cb(get(store)) | ||
this.set(value) | ||
updateStorage(key, value) | ||
set(value) | ||
}, | ||
@@ -23,0 +32,0 @@ subscribe |
Sorry, the diff of this file is not supported yet
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
8911
219
10
1
47