buffer: throw on negative .allocUnsafe() argument
Checklist
-
tests and code linting passes -
a test and/or benchmark is included -
the commit message follows commit guidelines
Affected core subsystem(s)
buffer
Description of change
Add a check for size < 0
to assertSize()
, as passing a negative value almost certainly indicates a programming error.
This also lines up the behaviour of .allocUnsafe()
with the ones of .alloc()
and .allocUnsafeSlow()
(which previously threw errors from the Uint8Array constructor).