(buf, offset = 0, size)
| 118 | } |
| 119 | |
| 120 | function 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 | |
| 154 | function randomFill(buf, offset, size, callback) { |
| 155 | if (!isAnyArrayBuffer(buf) && !isArrayBufferView(buf)) { |
no test coverage detected
searching dependent graphs…