mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 11:59:00 +00:00
fix test-fs-assert-encoding-error.js
This commit is contained in:
@@ -763,6 +763,12 @@ function ReadStream(this: typeof ReadStream, pathOrFd, options) {
|
||||
options = { encoding: options };
|
||||
}
|
||||
|
||||
if (options.encoding && options.encoding !== "buffer") {
|
||||
if (!Buffer.isEncoding(options.encoding)) {
|
||||
throw $ERR_INVALID_ARG_VALUE("encoding", options.encoding, "is invalid encoding");
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isObject(options) && !$isCallable(options)) {
|
||||
throw new TypeError("Expected options to be an object or a string");
|
||||
}
|
||||
@@ -1070,6 +1076,16 @@ var WriteStreamClass = (WriteStream = function WriteStream(path, options = defau
|
||||
throw new TypeError("Expected options to be an object");
|
||||
}
|
||||
|
||||
if (typeof options === "string") {
|
||||
options = { encoding: options };
|
||||
}
|
||||
|
||||
if (options.encoding && options.encoding !== "buffer") {
|
||||
if (!Buffer.isEncoding(options.encoding)) {
|
||||
throw $ERR_INVALID_ARG_VALUE("encoding", options.encoding, "is invalid encoding");
|
||||
}
|
||||
}
|
||||
|
||||
var {
|
||||
fs = defaultWriteStreamOptions.fs,
|
||||
start = defaultWriteStreamOptions.start,
|
||||
|
||||
Reference in New Issue
Block a user