react-native-onyx 1.0.108 → 1.0.110
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.
|
@@ -102,7 +102,10 @@ const provider = {
|
|
|
102
102
|
* @param {String} key
|
|
103
103
|
* @return {Promise<*>}
|
|
104
104
|
*/
|
|
105
|
-
getItem: key => get(key, getCustomStore())
|
|
105
|
+
getItem: key => get(key, getCustomStore())
|
|
106
|
+
|
|
107
|
+
// idb-keyval returns undefined for missing items, but this needs to return null so that idb-keyval does the same thing as SQLiteStorage.
|
|
108
|
+
.then(val => (val === undefined ? null : val)),
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
111
|
* Remove given key and it's value from storage
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges two objects and removes null values if "shouldRemoveNullObjectValues" is set to true
|
|
3
|
+
*
|
|
4
|
+
* We generally want to remove null values from objects written to disk and cache, because it decreases the amount of data stored in memory and on disk.
|
|
5
|
+
* On native, when merging an existing value with new changes, SQLite will use JSON_PATCH, which removes top-level nullish values.
|
|
6
|
+
* To be consistent with the behaviour for merge, we'll also want to remove null values for "set" operations.
|
|
7
|
+
*/
|
|
8
|
+
declare function fastMerge<T>(
|
|
9
|
+
target: T,
|
|
10
|
+
source: T,
|
|
11
|
+
shouldRemoveNullObjectValues: boolean = true
|
|
12
|
+
): T;
|
|
13
|
+
|
|
14
|
+
export default { fastMerge };
|