summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_fs/_fs_futimes.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/_fs/_fs_futimes.ts')
-rw-r--r--ext/node/polyfills/_fs/_fs_futimes.ts16
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/node/polyfills/_fs/_fs_futimes.ts b/ext/node/polyfills/_fs/_fs_futimes.ts
index cc4e35b0b..98cd1066c 100644
--- a/ext/node/polyfills/_fs/_fs_futimes.ts
+++ b/ext/node/polyfills/_fs/_fs_futimes.ts
@@ -5,6 +5,9 @@
import type { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
import { FsFile } from "ext:deno_fs/30_fs.js";
+import { validateInteger } from "ext:deno_node/internal/validators.mjs";
+import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
+import { toUnixTimestamp } from "ext:deno_node/internal/fs/utils.mjs";
function getValidTime(
time: number | string | Date,
@@ -23,7 +26,7 @@ function getValidTime(
);
}
- return time;
+ return toUnixTimestamp(time);
}
export function futimes(
@@ -35,6 +38,11 @@ export function futimes(
if (!callback) {
throw new Deno.errors.InvalidData("No callback function supplied");
}
+ if (typeof fd !== "number") {
+ throw new ERR_INVALID_ARG_TYPE("fd", "number", fd);
+ }
+
+ validateInteger(fd, "fd", 0, 2147483647);
atime = getValidTime(atime, "atime");
mtime = getValidTime(mtime, "mtime");
@@ -51,6 +59,12 @@ export function futimesSync(
atime: number | string | Date,
mtime: number | string | Date,
) {
+ if (typeof fd !== "number") {
+ throw new ERR_INVALID_ARG_TYPE("fd", "number", fd);
+ }
+
+ validateInteger(fd, "fd", 0, 2147483647);
+
atime = getValidTime(atime, "atime");
mtime = getValidTime(mtime, "mtime");