diff --git a/package.json b/package.json index d942fb30..89c1ea0d 100644 --- a/package.json +++ b/package.json @@ -57,9 +57,6 @@ "react": "^16.8", "react-native": ">=0.59" }, - "dependencies": { - "deep-assign": "^3.0.0" - }, "devDependencies": { "@babel/core": "^7.6.2", "@babel/runtime": "^7.6.2", diff --git a/src/AsyncStorage.js b/src/AsyncStorage.js index 020d16ef..db88a4bf 100644 --- a/src/AsyncStorage.js +++ b/src/AsyncStorage.js @@ -8,13 +8,22 @@ * @flow */ -import merge from 'deep-assign'; +const merge = (target = {}, source = {}) => { + for (const key of Object.keys(source)) { + if (source[key] instanceof Object) { + Object.assign(source[key], merge(target[key], source[key])); + } else { + source[key] = target[key] || source[key]; + } + } + return Object.assign(target, source); +}; const mergeLocalStorageItem = (key, value) => { const oldValue = window.localStorage.getItem(key); const oldObject = JSON.parse(oldValue); const newObject = JSON.parse(value); - const nextValue = JSON.stringify(merge({}, oldObject, newObject)); + const nextValue = JSON.stringify(merge(oldObject, newObject)); window.localStorage.setItem(key, nextValue); };