From 795299c49204817d1958e83f4d60fe50e5c30714 Mon Sep 17 00:00:00 2001
From: rickyes <mail@zhoumq.cn>
Date: Fri, 3 Apr 2020 20:30:14 +0800
Subject: [PATCH] fs: Use constant kWriteFileMaxChunkSize

---
 lib/internal/fs/promises.js | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js
index d04e84aa9aa859..957e5b731981e5 100644
--- a/lib/internal/fs/promises.js
+++ b/lib/internal/fs/promises.js
@@ -4,6 +4,11 @@
 // See https://github.com/libuv/libuv/pull/1501.
 const kIoMaxLength = 2 ** 31 - 1;
 
+// Note: This is different from kReadFileBufferLength used for non-promisified
+// fs.readFile.
+const kReadFileMaxChunkSize = 2 ** 14;
+const kWriteFileMaxChunkSize = 2 ** 14;
+
 const {
   MathMax,
   MathMin,
@@ -150,16 +155,12 @@ async function writeFileHandle(filehandle, data, options) {
   do {
     const { bytesWritten } =
       await write(filehandle, data, 0,
-                  MathMin(16384, data.length));
+                  MathMin(kWriteFileMaxChunkSize, data.length));
     remaining -= bytesWritten;
     data = data.slice(bytesWritten);
   } while (remaining > 0);
 }
 
-// Note: This is different from kReadFileBufferLength used for non-promisified
-// fs.readFile.
-const kReadFileMaxChunkSize = 16384;
-
 async function readFileHandle(filehandle, options) {
   const statFields = await binding.fstat(filehandle.fd, false, kUsePromises);