From 6f933e5d03b079ceec9ab359e8c9342092345fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Isager=20Dalsgar=C3=B0?= Date: Tue, 11 Jun 2024 10:43:00 +0200 Subject: [PATCH] Formatting --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6302226..754cd8f 100644 --- a/index.js +++ b/index.js @@ -81,11 +81,12 @@ const randomFill = exports.randomFill = function randomFill (buffer, offset, siz if (size < 0 || size > buffer.byteLength) throw new RangeError('size is out of range') if (offset + size > buffer.byteLength) throw new RangeError('offset + size is out of range') - const isView = ArrayBuffer.isView(buffer) - - if (isView) offset += buffer.byteOffset + if (ArrayBuffer.isView(buffer)) { + offset += buffer.byteOffset + buffer = buffer.buffer + } - binding.randomFill(isView ? buffer.buffer : buffer, offset, size) + binding.randomFill(buffer, offset, size) if (cb) queueMicrotask(() => cb(null, buffer)) else return buffer