mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 13:22:07 +00:00
fix fs-non-number-arguments-throw.test.js (#14312)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user