-
Notifications
You must be signed in to change notification settings - Fork 70
Description
I struggle to understand why crypto.getRandomValues
doesn't accept a DataView
object?
Indeed, the spec. says:
If array is not an
Int8Array
,Uint8Array
,Uint8ClampedArray
,Int16Array
,Uint16Array
,Int32Array
,Uint32Array
,BigInt64Array
, orBigUint64Array
, then throw aTypeMismatchError
and terminate the algorithm.
Is there any reason why DataView
isn't among these acceptable classes of objects? Does the procedure actually utilize different writing granularity depending on what kind of typed array it is provided, and hence it wouldn't be meaningful for it to work with a view? It could access the underlying buffer anyway, wouldn't it? I mean, this would certainly be implementation defined -- how the procedure loads the underlying buffer with the random data -- but can't a case be made that if all of the above are allowed, principally providing access to an underlying buffer, then so should be DataView
? That's what it's for, isn't it? On that note, even passing ArrayBuffer
could be acceptable then, on the same argument, no?
Apologies if I have missed something obvious.