@umituz/react-native-storage 2.3.2 → 2.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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-storage",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Zustand state management with AsyncStorage persistence and type-safe storage operations for React Native",
|
|
5
|
-
"main": "./
|
|
6
|
-
"types": "./
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"types": "./src/index.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
9
|
"typecheck": "tsc --noEmit",
|
|
@@ -60,9 +60,8 @@
|
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
62
|
"files": [
|
|
63
|
-
"lib",
|
|
64
63
|
"src",
|
|
65
64
|
"README.md",
|
|
66
65
|
"LICENSE"
|
|
67
66
|
]
|
|
68
|
-
}
|
|
67
|
+
}
|
|
@@ -53,7 +53,11 @@ export const unwrap = <T>(result: StorageResult<T>, defaultValue: T): T => {
|
|
|
53
53
|
if (isSuccess(result)) {
|
|
54
54
|
return result.data;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
// Type guard ensures we can access fallback
|
|
57
|
+
if (isFailure(result) && result.fallback !== undefined) {
|
|
58
|
+
return result.fallback;
|
|
59
|
+
}
|
|
60
|
+
return defaultValue;
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
/**
|
|
@@ -66,5 +70,6 @@ export const map = <T, U>(
|
|
|
66
70
|
if (isSuccess(result)) {
|
|
67
71
|
return success(fn(result.data));
|
|
68
72
|
}
|
|
73
|
+
// For failure, we can't convert fallback type T to U, so we omit it
|
|
69
74
|
return failure(result.error);
|
|
70
75
|
};
|