summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_fs/_fs_write.mjs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-05-26 16:18:27 +0200
committerGitHub <noreply@github.com>2023-05-26 16:18:27 +0200
commita11681a9b02f2f4a0f2bf6945a44b2937c6a9af1 (patch)
tree55b3a63959b2a935a86c30d8282fbe294f2bb892 /ext/node/polyfills/_fs/_fs_write.mjs
parentd72e0281ff41a87c32aefd0876bace23470a4dc5 (diff)
refactor(node): use internal io and fs APIs (#19267)
Diffstat (limited to 'ext/node/polyfills/_fs/_fs_write.mjs')
-rw-r--r--ext/node/polyfills/_fs/_fs_write.mjs10
1 files changed, 6 insertions, 4 deletions
diff --git a/ext/node/polyfills/_fs/_fs_write.mjs b/ext/node/polyfills/_fs/_fs_write.mjs
index bd0ffd105..fd7a1171c 100644
--- a/ext/node/polyfills/_fs/_fs_write.mjs
+++ b/ext/node/polyfills/_fs/_fs_write.mjs
@@ -2,6 +2,8 @@
// Copyright Joyent, Inc. and Node.js contributors. All rights reserved. MIT license.
import { Buffer } from "ext:deno_node/buffer.ts";
import { validateEncoding, validateInteger } from "ext:deno_node/internal/validators.mjs";
+import * as io from "ext:deno_io/12_io.js";
+import * as fs from "ext:deno_fs/30_fs.js";
import {
getValidatedFd,
showStringCoercionDeprecation,
@@ -19,12 +21,12 @@ export function writeSync(fd, buffer, offset, length, position) {
buffer = new Uint8Array(buffer.buffer);
}
if (typeof position === "number") {
- Deno.seekSync(fd, position, Deno.SeekMode.Start);
+ fs.seekSync(fd, position, io.SeekMode.Start);
}
let currentOffset = offset;
const end = offset + length;
while (currentOffset - offset < length) {
- currentOffset += Deno.writeSync(fd, buffer.subarray(currentOffset, end));
+ currentOffset += io.writeSync(fd, buffer.subarray(currentOffset, end));
}
return currentOffset - offset;
};
@@ -65,12 +67,12 @@ export function write(fd, buffer, offset, length, position, callback) {
buffer = new Uint8Array(buffer.buffer);
}
if (typeof position === "number") {
- await Deno.seek(fd, position, Deno.SeekMode.Start);
+ await fs.seek(fd, position, io.SeekMode.Start);
}
let currentOffset = offset;
const end = offset + length;
while (currentOffset - offset < length) {
- currentOffset += await Deno.write(
+ currentOffset += await io.write(
fd,
buffer.subarray(currentOffset, end),
);