Skip to content

Commit

Permalink
new cloneDeep from lodash dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurgermano committed Aug 31, 2022
1 parent dfdf469 commit 67df8ad
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 26 deletions.
18 changes: 9 additions & 9 deletions docs/assets/index.df9d6696.js → docs/assets/index.ff36de37.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/assets/lodash.clonedeep.670c0659.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.png" />
<meta name='viewport' content='width=device-width,initial-scale=1'>
<meta name="description" content="The SPA Storage for Svelte and Pinia Stores">
<meta name="Keywords" content="svelte, pinia, storage, store, plugin">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SPA Storage</title>
<script type="module" crossorigin src="/spa-storage/assets/index.df9d6696.js"></script>
<link rel="modulepreload" crossorigin href="/spa-storage/assets/svelte.14eddbdd.js">
<link rel="modulepreload" crossorigin href="/spa-storage/assets/crypto-js.2e94412d.js">
<link rel="modulepreload" crossorigin href="/spa-storage/assets/localforage.59b7b911.js">
<link rel="stylesheet" href="/spa-storage/assets/index.13bc1b05.css">
<script type="module" crossorigin src="/assets/index.ff36de37.js"></script>
<link rel="modulepreload" crossorigin href="/assets/svelte.14eddbdd.js">
<link rel="modulepreload" crossorigin href="/assets/crypto-js.2e94412d.js">
<link rel="modulepreload" crossorigin href="/assets/localforage.59b7b911.js">
<link rel="modulepreload" crossorigin href="/assets/lodash.clonedeep.670c0659.js">
<link rel="stylesheet" href="/assets/index.13bc1b05.css">
</head>
<body>
<div id="app"></div>

</body>
</html>
3 changes: 2 additions & 1 deletion functions/piniaFunctions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { setItem, getItem } from "./storageFunctions.js";
import cloneDeep from "lodash.clonedeep";

// ------------------------------------------------------------------------------------------------
// ----------------------------- setPiniaStoreInStorage -----------------------------------------
Expand Down Expand Up @@ -45,7 +46,7 @@ export async function getPiniaStoreInStorage(store, key) {
if (!storage) {
return;
}
store.$patch(Object.assign({}, structuredClone(storage)));
store.$patch(Object.assign({}, cloneDeep(storage)));
return true;
} catch (error) {
throw error;
Expand Down
9 changes: 5 additions & 4 deletions functions/svelteFunctions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { setItem, getItem } from "./storageFunctions.js";
import cloneDeep from "lodash.clonedeep";

// ------------------------------------------------------------------------------------------------
// ----------------------------- getStoreState --------------------------------------------------
Expand All @@ -9,7 +10,7 @@ export const getStoreState = (store) => {
let storeState;
const unsubscribe = store.subscribe((state) => {
if (typeof state === "object" || Array.isArray(state)) {
storeState = structuredClone(state);
storeState = cloneDeep(state);
return;
}
storeState = state;
Expand Down Expand Up @@ -44,8 +45,8 @@ export const updateStoreKey = (store, objectKeyValue, storeStateSubstitute) => {
checkStore(store);
store.update((storeState) => {
return Object.assign(
structuredClone(storeStateSubstitute || storeState),
structuredClone(objectKeyValue)
cloneDeep(storeStateSubstitute || storeState),
cloneDeep(objectKeyValue)
);
});
} catch (error) {
Expand Down Expand Up @@ -79,7 +80,7 @@ export async function getSvelteStoreInStorage(store, key) {
return;
}
store.update(() => {
return Object.assign({}, structuredClone(storage));
return Object.assign({}, cloneDeep(storage));
});
return true;
} catch (error) {
Expand Down
13 changes: 12 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spa-storage",
"version": "2.0.0",
"version": "2.0.1",
"type": "module",
"description": "Browser Storage plugin for Svelte and Pinia",
"main": "index.js",
Expand All @@ -26,7 +26,8 @@
"homepage": "https://arthurgermano.github.io/spa-storage/",
"dependencies": {
"crypto-js": "^4.1.1",
"localforage": "^1.10.0"
"localforage": "^1.10.0",
"lodash.clonedeep": "^4.5.0"
},
"devDependencies": {
"@vue/composition-api": "^1.7.0",
Expand All @@ -35,4 +36,4 @@
"svelte": "^3.49.0",
"vitest": "^0.21.1"
}
}
}

0 comments on commit 67df8ad

Please sign in to comment.