Skip to content

Commit 74d7ad1

Browse files
committed
Throw for unsupported
1 parent f85a3cf commit 74d7ad1

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/react-fs/src/ReactFilesystem.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,21 @@ export function readFile(
9191
if (!options) {
9292
return result;
9393
}
94-
const encoding = typeof options === 'string' ? options : options.encoding;
94+
let encoding;
95+
if (typeof options === 'string') {
96+
encoding = options;
97+
} else {
98+
const flag = options.flag;
99+
if (flag != null && flag !== 'r') {
100+
throw Error(
101+
'The flag option is not supported, and always defaults to "r".',
102+
);
103+
}
104+
if (options.signal) {
105+
throw Error('The signal option is not supported.');
106+
}
107+
encoding = options.encoding;
108+
}
95109
if (typeof encoding !== 'string') {
96110
return result;
97111
}

0 commit comments

Comments
 (0)