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

Function assertSize

lib/internal/crypto/random.js:84–98  ·  view source on GitHub ↗
(size, elementSize, offset, length)

Source from the content-addressed store, hash-verified

82}
83
84function assertSize(size, elementSize, offset, length) {
85 validateNumber(size, 'size');
86 size *= elementSize;
87
88 if (NumberIsNaN(size) || size > kMaxPossibleLength || size < 0) {
89 throw new ERR_OUT_OF_RANGE('size',
90 `>= 0 && <= ${kMaxPossibleLength}`, size);
91 }
92
93 if (size + offset > length) {
94 throw new ERR_OUT_OF_RANGE('size + offset', `<= ${length}`, size + offset);
95 }
96
97 return size >>> 0; // Convert to uint32.
98}
99
100function randomBytes(size, callback) {
101 size = assertSize(size, 1, 0, Infinity);

Callers 3

randomBytesFunction · 0.70
randomFillSyncFunction · 0.70
randomFillFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…