@umituz/react-native-storage 1.2.1 → 1.4.0
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/package.json
CHANGED
|
@@ -41,7 +41,9 @@ export const unwrap = <T>(result: StorageResult<T>, defaultValue: T): T => {
|
|
|
41
41
|
if (result.success) {
|
|
42
42
|
return result.data;
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
// result is now narrowed to failure type
|
|
45
|
+
const failedResult = result;
|
|
46
|
+
return failedResult.fallback !== undefined ? failedResult.fallback : defaultValue;
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
/**
|
|
@@ -54,5 +56,7 @@ export const map = <T, U>(
|
|
|
54
56
|
if (result.success) {
|
|
55
57
|
return success(fn(result.data));
|
|
56
58
|
}
|
|
57
|
-
|
|
59
|
+
// result is now narrowed to failure type
|
|
60
|
+
const failedResult = result;
|
|
61
|
+
return failure(failedResult.error, failedResult.fallback !== undefined ? fn(failedResult.fallback) : undefined);
|
|
58
62
|
};
|