Skip to content

Commit

Permalink
Throw for unsupported
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Dec 9, 2020
1 parent f85a3cf commit 74d7ad1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/react-fs/src/ReactFilesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,21 @@ export function readFile(
if (!options) {
return result;
}
const encoding = typeof options === 'string' ? options : options.encoding;
let encoding;
if (typeof options === 'string') {
encoding = options;
} else {
const flag = options.flag;
if (flag != null && flag !== 'r') {
throw Error(
'The flag option is not supported, and always defaults to "r".',
);
}
if (options.signal) {
throw Error('The signal option is not supported.');
}
encoding = options.encoding;
}
if (typeof encoding !== 'string') {
return result;
}
Expand Down

0 comments on commit 74d7ad1

Please sign in to comment.