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

Function randomFillSync

lib/internal/crypto/random.js:120–152  ·  view source on GitHub ↗
(buf, offset = 0, size)

Source from the content-addressed store, hash-verified

118}
119
120function randomFillSync(buf, offset = 0, size) {
121 if (!isAnyArrayBuffer(buf) && !isArrayBufferView(buf)) {
122 throw new ERR_INVALID_ARG_TYPE(
123 'buf',
124 ['ArrayBuffer', 'ArrayBufferView'],
125 buf);
126 }
127
128 const elementSize = buf.BYTES_PER_ELEMENT || 1;
129
130 offset = assertOffset(offset, elementSize, buf.byteLength);
131
132 if (size === undefined) {
133 size = buf.byteLength - offset;
134 } else {
135 size = assertSize(size, elementSize, offset, buf.byteLength);
136 }
137
138 if (size === 0)
139 return buf;
140
141 const job = new RandomBytesJob(
142 kCryptoJobSync,
143 buf,
144 offset,
145 size);
146
147 const err = job.run()[0];
148 if (err)
149 throw err;
150
151 return buf;
152}
153
154function randomFill(buf, offset, size, callback) {
155 if (!isAnyArrayBuffer(buf) && !isArrayBufferView(buf)) {

Callers 10

randomBytesFunction · 0.85
randomIntFunction · 0.85
getRandomValuesFunction · 0.85
getBufferedUUIDFunction · 0.85
getUnbufferedUUIDFunction · 0.85
getBufferedUUIDv7Function · 0.85
getUnbufferedUUIDv7Function · 0.85
generateMaskFunction · 0.85
generateMaskFunction · 0.85

Calls 3

assertOffsetFunction · 0.85
assertSizeFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…