Skip to content

Commit d26019c

Browse files
committed
refactor: update unwrap calls to eliminate default error messages
1 parent c6e0618 commit d26019c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/common/json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const unsafeParse = <T = any>(
3131
const result = safeParse<T>(text, reviver);
3232
if (result.isErr()) return undefined;
3333

34-
return result.unwrap();
34+
return result.unwrap(null);
3535
};
3636

3737
export { safeParse, unsafeParse as parse };

src/fs/unsafe.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export async function readFile(path: any, options?: any): Promise<any> {
8787
const result = await safeReadFile(path, options);
8888
if (result.isErr()) return undefined;
8989

90-
return result.unwrap();
90+
return result.unwrap(null);
9191
}
9292

9393
export function readFileSync(path: PathLike, options: BufferEncodingOptions): Buffer | undefined;
@@ -96,7 +96,7 @@ export function readFileSync(path: any, options?: any): any {
9696
const result = safeReadFileSync(path, options);
9797
if (result.isErr()) return undefined;
9898

99-
return result.unwrap();
99+
return result.unwrap(null);
100100
}
101101

102102
export const readFileByLine = async (
@@ -106,7 +106,7 @@ export const readFileByLine = async (
106106
const result = await safeReadFileByLine(path, options);
107107
if (result.isErr()) return undefined;
108108

109-
return result.unwrap();
109+
return result.unwrap(null);
110110
};
111111

112112
export const readJson = async <T = any>(
@@ -116,7 +116,7 @@ export const readJson = async <T = any>(
116116
const result = await safeReadJson(path, options);
117117
if (result.isErr()) return undefined;
118118

119-
return result.unwrap();
119+
return result.unwrap(null);
120120
};
121121

122122
export const readJsonSync = <T = any>(
@@ -126,7 +126,7 @@ export const readJsonSync = <T = any>(
126126
const result = safeReadJsonSync(path, options);
127127
if (result.isErr()) return undefined;
128128

129-
return result.unwrap();
129+
return result.unwrap(null);
130130
};
131131

132132
export const rm = async (path: PathLike, options?: RmOptions): Promise<void> => {

0 commit comments

Comments
 (0)