@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-storage",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "Domain-Driven Design storage system for React Native apps with type-safe AsyncStorage operations",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -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
- return result.fallback ?? defaultValue;
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
- return result as StorageResult<U>;
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
  };