react-native-onyx 1.0.25 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web.development.js +9 -0
- package/dist/web.development.js.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/lib/Onyx.js +5 -0
- package/lib/OnyxCache.js +4 -0
- package/package.json +1 -1
package/lib/Onyx.js
CHANGED
|
@@ -1046,6 +1046,11 @@ function clear() {
|
|
|
1046
1046
|
* @returns {Promise}
|
|
1047
1047
|
*/
|
|
1048
1048
|
function mergeCollection(collectionKey, collection) {
|
|
1049
|
+
if (!_.isObject(collection) || _.isArray(collection) || _.isEmpty(collection)) {
|
|
1050
|
+
Logger.logInfo('mergeCollection() called with invalid or empty value. Skipping this update.');
|
|
1051
|
+
return Promise.resolve();
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1049
1054
|
// Confirm all the collection keys belong to the same parent
|
|
1050
1055
|
_.each(collection, (_data, dataKey) => {
|
|
1051
1056
|
if (isKeyMatch(collectionKey, dataKey)) {
|
package/lib/OnyxCache.js
CHANGED
|
@@ -111,6 +111,10 @@ class OnyxCache {
|
|
|
111
111
|
* @param {Record<string, *>} data - a map of (cache) key - values
|
|
112
112
|
*/
|
|
113
113
|
merge(data) {
|
|
114
|
+
if (!_.isObject(data) || _.isArray(data)) {
|
|
115
|
+
throw new Error('data passed to cache.merge() must be an Object of onyx key/value pairs');
|
|
116
|
+
}
|
|
117
|
+
|
|
114
118
|
// lodash adds a small overhead so we don't use it here
|
|
115
119
|
// eslint-disable-next-line prefer-object-spread, rulesdir/prefer-underscore-method
|
|
116
120
|
this.storageMap = Object.assign({}, fastMerge(this.storageMap, data));
|