From c791a7f03d8f38c2c71b2453b6db0bfc673b8849 Mon Sep 17 00:00:00 2001 From: Elliott Sprehn Date: Tue, 10 Jul 2018 16:03:19 -0700 Subject: [PATCH] Fix AsyncStorage mergeItem and multiMerge They should do deep merges and multiMerge had Object.assign misspelled. --- src/api/AsyncStorage.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/AsyncStorage.js b/src/api/AsyncStorage.js index 94655e4..b484516 100644 --- a/src/api/AsyncStorage.js +++ b/src/api/AsyncStorage.js @@ -2,6 +2,8 @@ * https://github.com/facebook/react-native/blob/master/Libraries/Storage/AsyncStorage.js */ +import * as lodash from 'lodash'; + function wrap(value, callback) { return Promise.resolve(value).then( obj => { @@ -37,7 +39,7 @@ const AsyncStorage = { }, mergeItem(key, value, callback) { - db[key] = Object.assign({}, db[key] || {}, value); + db[key] = lodash.merge({}, db[key] || {}, value); return wrap(null, callback); }, @@ -72,7 +74,7 @@ const AsyncStorage = { multiMerge(keyValuePairs, callback) { keyValuePairs.forEach(([key, value]) => { - db[key] = Object.asign({}, db[key] || {}, value); + db[key] = lodash.merge({}, db[key] || {}, value); }); return wrap(null, callback); },