MCPcopy Index your code
hub / github.com/nodejs/node / getRandomValues

Function getRandomValues

lib/internal/crypto/random.js:319–338  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

317// not allowed to exceed 65536 bytes, and can only
318// be an integer-type TypedArray.
319function getRandomValues(data) {
320 if (!isTypedArray(data) ||
321 isFloat16Array(data) ||
322 isFloat32Array(data) ||
323 isFloat64Array(data)) {
324 // Ordinarily this would be an ERR_INVALID_ARG_TYPE. However,
325 // the Web Crypto API and web platform tests expect this to
326 // be a DOMException with type TypeMismatchError.
327 throw lazyDOMException(
328 'The data argument must be an integer-type TypedArray',
329 'TypeMismatchError');
330 }
331 if (data.byteLength > 65536) {
332 const { QuotaExceededError } = internalBinding('messaging');
333 throw new QuotaExceededError(
334 'The requested length exceeds 65,536 bytes');
335 }
336 randomFillSync(data, 0);
337 return data;
338}
339
340// Implements an RFC 4122 version 4 random UUID.
341// To improve performance, random data is generated in batches

Callers

nothing calls this directly

Calls 6

isTypedArrayFunction · 0.85
isFloat16ArrayFunction · 0.85
isFloat32ArrayFunction · 0.85
isFloat64ArrayFunction · 0.85
lazyDOMExceptionFunction · 0.85
randomFillSyncFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…