fix fs-non-number-arguments-throw.test.js (#14312)

This commit is contained in:
Meghan Denny
2024-10-10 22:07:41 -07:00
committed by GitHub
parent 874c9dbb24
commit 170fafbca9
3 changed files with 86 additions and 1 deletions

View File

@@ -5,6 +5,9 @@ const promises = require("node:fs/promises");
const Stream = require("node:stream");
const types = require("node:util/types");
const { ERR_INVALID_ARG_TYPE, ERR_OUT_OF_RANGE } = require("internal/errors");
const { validateInteger } = require("internal/validators");
const NumberIsFinite = Number.isFinite;
const DateNow = Date.now;
const DatePrototypeGetTime = Date.prototype.getTime;
@@ -830,6 +833,18 @@ function ReadStream(this: typeof ReadStream, pathOrFd, options) {
// Get the stream controller
// We need the pointer to the underlying stream controller for the NativeReadable
if (start !== undefined) {
validateInteger(start, "start", 0);
}
if (end === undefined) {
end = Infinity;
} else if (end !== Infinity) {
validateInteger(end, "end", 0);
if (start !== undefined && start > end) {
throw new ERR_OUT_OF_RANGE("start", `<= "end" (here: ${end})`, start);
}
}
const stream = blobToStreamWithOffset.$apply(fileRef, [start]);
var ptr = stream.$bunNativePtr;
if (!ptr) {
@@ -1068,6 +1083,11 @@ var WriteStreamClass = (WriteStream = function WriteStream(path, options = defau
pos = defaultWriteStreamOptions.pos,
} = options;
if (start !== undefined) {
validateInteger(start, "start", 0);
options.pos = start;
}
var tempThis = {};
var handle = null;
if (fd != null) {