From 30782e007630c428da211c2d558b7408e9ea7999 Mon Sep 17 00:00:00 2001 From: Andreas Hippler Date: Wed, 3 Aug 2022 19:57:47 +0200 Subject: [PATCH] fix: TypeError: Cannot convert to a BigInt --- lib/binding.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/binding.js b/lib/binding.js index 5fcde9a..6801f95 100644 --- a/lib/binding.js +++ b/lib/binding.js @@ -273,8 +273,8 @@ Binding.prototype.realpath = function (filepath, encoding, callback, ctx) { }); }; -function fillStats(stats) { - const target = stats instanceof Float64Array ? statValues : bigintStatValues; +function fillStats(stats, bigint) { + const target = bigint ? bigintStatValues : statValues; for (let i = 0; i < 36; i++) { target[i] = stats[i]; } @@ -303,7 +303,7 @@ Binding.prototype.stat = function (filepath, bigint, callback, ctx) { throw new FSError('ENOENT', filepath); } const stats = item.getStats(bigint); - fillStats(stats); + fillStats(stats, bigint); return stats; }); }; @@ -323,7 +323,7 @@ Binding.prototype.fstat = function (fd, bigint, callback, ctx) { const descriptor = this.getDescriptorById(fd); const item = descriptor.getItem(); const stats = item.getStats(bigint); - fillStats(stats); + fillStats(stats, bigint); return stats; }); }; @@ -1252,7 +1252,7 @@ Binding.prototype.lstat = function (filepath, bigint, callback, ctx) { throw new FSError('ENOENT', filepath); } const stats = item.getStats(bigint); - fillStats(stats); + fillStats(stats, bigint); return stats; }); };