Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Jun 11, 2024
1 parent 8ac0017 commit 6f933e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6f933e5

Please sign in to comment.